Simple question. I noticed you cannot use php variables within channel tag parameters, or the query module. How would I accomplish something like this?
For example I am using structure for handling pages and the client has the ability to add and edit pages. There is a custom field assign to a pages channel named “page_header”. This is a file field type that adds is the page header image. I want to write an if statement that basically goes like this—-> if the page contains a page header, display it, else if it has a parent page with a page header, use that, finally if neither, then use a default image.
The problem comes when I am trying to use a channel tag with dynamic off to pull in it’s top level page’s page header. First I get the parent page’s id like this…
{exp:channel:entries channel="pages"}
{exp:query sql="SELECT parent_id FROM exp_structure WHERE entry_id = '{entry_id}'"}
<?php $parent_id = "{parent_id}"; ?>
{/exp:query}
{/exp:channel:entries}So now I would like to be able to do something like this…. obviously the php variable will not work like this below, but given the concept, any ideas on how to accomplish getting a php variable within a tag parameter for this kind of purpose?
{exp:channel:entries channel="pages" dynamic="off" entry_id="$parent_id"}
{pages_header_img}
{/exp:channel:entries}I also tried to put another channel entry tag again within the first like this… but that didn’t work either.
{exp:channel:entries channel="pages"}
{exp:query sql="SELECT parent_id FROM exp_structure WHERE entry_id = '{entry_id}'"}
{exp:channel:entries channel="pages" dynamic="off" entry_id="{parent_id}"}
{pages_header_img}
{/exp:channel:entries}
{/exp:query}
{/exp:channel:entries}