Closed lindseydiloreto closed 9 years ago
To clarify, I mean the ability to pull config
values in as part of the URL...
In hindsight, {siteUrl}
isn't really used anymore in these circumstances... Now, it's more often referred to as {baseUrl}
.
This is a great idea! Hadn't even thought about this :) Seems reasonably feasible.
Check out how I did it in the CP CSS plugin... it's actually pretty straightforward!
Nice one - that's pretty nifty!
Hmmm - I'm no expert, but shouldn't this work in modifyCpNav()
?
$nav[$newNav->handle] = array(
'label' => $newNav->currLabel,
'url' => craft()->config->parseEnvironmentString(trim($newNav->url)),
);
Just keeps outputting the raw {siteUrl}
tag...
Do you have siteUrl
defined in your environment variables? If not, it won't get parsed out at all.
To be honest, I kinda misspoke when I said siteUrl
... These days, it's almost always referenced as baseUrl
. There was a lot of confusion back in the day about what "siteUrl" meant in different contexts, so Brandon tweaked the docs to make "baseUrl" the standard for environment variables.
Yeah, I have it defined, I've also tried baseUrl, which I've defined too. Strange.
Weird, I'd think that would work.
Does your {baseUrl}
tag contain any spaces? It shouldn't.
Try this for debugging:
$url = craft()->config->parseEnvironmentString(trim($newNav->url));
Craft::dd($url);
$nav[$newNav->handle] = array(
'label' => $newNav->currLabel,
'url' => $url,
);
What does that output?
I'm using $url = craft()->config->parseEnvironmentString('{baseUrl}/test');
just to be extra sure. It outputs {baseUrl}/test
. What about you?
I'm actually not testing on my end, but what you have looks right. Might be worth emailing P&T to find out what might be going on.
I feel like there's a 1% chance that perhaps the environment variables just haven't been set by the time modifyCpNav
is called. Seems strange and unlikely, but I can't imagine what else might be causing the problem.
Looks like you got this working beautifully!
It's only acting weird when you initially make the change... though I'm assuming it's using JS to change the nav tabs instantly.
Good point, thats now fixed as well.
Should {siteUrl}
or {baseUrl}
be working out of the box? Or do I have to modify something? It's just outputting trigger/{siteUrl}/path
at the moment ...
@badlydrawnrob: You'll need to have {baseUrl}
defined in your environment variables...
I'd love to have {siteUrl}
available, but couldn't get it to work from memory. Might have another crack. In the meantime, as @lindseydiloreto points out, the {baseUrl}
in your environment variables works a treat.
@engram-design yup, would be handy to have if it's doable. @lindseydiloreto Hmm, {baseUrl}
is defined but it just isn't working for me (outputting as if it's a relative url as I've mentioned earlier). I have cpTrigger
set, some front-end form settings and the following:
'.dev' => array(
'devMode' => true,
'siteUrl' => 'http://site.dev/',
'environmentVariables' => array(
'basePath' => '/home/vagrant/site/html/',
'baseUrl' => 'http://site.dev/',
),
'enableTemplateCaching' => false,
),
@badlydrawnrob Ah - you're certainly correct, there's a minor bug that caused this not to work, which is now fixed in the 1.7.2 release
@engram-design Perfect. That'll save me some headaches between dev/live deploys :+1: ... is it safe to just replace the plugin folder?
FYI - {siteUrl}
is now supported in the 1.7.3 release.
Sorry for blowing up your Github issues... :)
It would be great if the URL supported
{siteUrl}
to reference front-end pages. This is crucial for multi-environment setups.