Page 1 of 1

UDT, PHP and Page content values RESOLVED

Posted: Mon Nov 25, 2013 5:05 pm
by lancester
Hello, i am stuck in a "simple" task. I have an UDT in wich i want to call a variable defined in a page. For instance i have my UDT that execute a SQL query (from a PHP script) embeded in my page A.

In page A i want the query execute on a WHERE clause for instance ...SELECT ... WHERE items="VALUEFROMPAGEA" in order to contextualize my content.

In page B i want the query execute on a WHERE clause for instance ...SELECT ... WHERE items="VALUEFROMPAGEB". etc...

How can i achieve this simply and more elegantly ?

Thank you

Re: UDT, PHP and Page content values

Posted: Mon Nov 25, 2013 6:18 pm
by Wishbone
You can pass parameters to UDTs.

In the page or template, call:

Code: Select all

{myudt myval='abc'}
or

Code: Select all

{myudt myval='def'}
Inside your UDT, you can use:

Code: Select all

$params['myval']
..to reference your parameter.

Change 'myval' to whatever variable name you want. You can also pass multiple parameters.

Re: UDT, PHP and Page content values

Posted: Tue Nov 26, 2013 1:56 pm
by lancester
Wishbone wrote:You can pass parameters to UDTs.

In the page or template, call:

Code: Select all

{myudt myval='abc'}
or

Code: Select all

{myudt myval='def'}
Inside your UDT, you can use:

Code: Select all

$params['myval']
..to reference your parameter.

Change 'myval' to whatever variable name you want. You can also pass multiple parameters.

Thank you for your quick answer. In my page i try to add {myudt myval='abc'} in a personnalized content block. (I understood that myudt is my own udt name).

It displays on the site as if it is text "{myudt myval='abc'}".

I tried several way without success. Are you sure i can add this as text into a block content into a page ?

Thank you

Re: UDT, PHP and Page content values [RESOLVED]

Posted: Tue Nov 26, 2013 3:12 pm
by lancester
Hello, it worked like a charm :-)