Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions

Concatenate variables


Reply

5 Posts   1872 Views

Avatar
CraigB

17 June 2009 at 10:04am Community Member, 7 Posts

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.htm

Where $ProductCode is "PW"

Thanks

Craig

Avatar
Howard

17 June 2009 at 11:35am Community Member, 215 Posts

Yup just go:

/products/{$ProductCode}Release/output/index.htm

:)

Avatar
CraigB

17 June 2009 at 11:49am Community Member, 7 Posts

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.

Avatar
Howard

17 June 2009 at 11:56am Community Member, 215 Posts

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';
}

Avatar
CraigB

17 June 2009 at 12:04pm Community Member, 7 Posts

Thanks again.

That seems like a bit of a limitation but at least there is a way to get it to work.

Cheers