2864 Posts in 732 Topics by 700 members
Template Questions
SilverStripe Forums » Template Questions » Concatenate variables
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba
|
Page:
1
|
Go to End | |
| Author | Topic: | 1354 Views |
-
Concatenate variables

17 June 2009 at 10:04am
I am trying to Take a custom field for a page and use it as a part of a link to some pre generated documentation.
The link has the following format:
/products/$ProductCode Release/output/index.htm
I want to be able to remove the space after $ProductCode.The result I want to endup with is as follows:
/products/PWRelease/output/index.htmWhere $ProductCode is "PW"
Thanks
Craig
-
Re: Concatenate variables

17 June 2009 at 11:35am
Yup just go:
/products/{$ProductCode}Release/output/index.htm
-
Re: Concatenate variables

17 June 2009 at 11:49am
Thanks for that.
You wouldn't also no how to use page variables in a function for the page?
ie. function DocURL() {
return '/products/'.$ProductCode.'Release/output/index.htm';
}This doesn't seem to work, the Product code is never populated.
-
Re: Concatenate variables

17 June 2009 at 11:56am
Yea you cant use template variables in the php code but you can do:
function DocURL() {
$product = $this->ProductCode;
return '/products/'.$product.'Release/output/index.htm';
} -
Re: Concatenate variables

17 June 2009 at 12:04pm
Thanks again.
That seems like a bit of a limitation but at least there is a way to get it to work.
Cheers
| 1354 Views | ||
|
Page:
1
|
Go to Top |
