Get Child Page Attribute and write out div
Permalink
Hi,
I have an Pages Attribute I created called price_reduced.
I've added this to a page and use the following code to write a div in my page:
This works great, but I also have a page list and I want to get the attribute of the child pages in that list and write out a div in my list.
Im using page list teasers add-on and my code for my list looks like this so far:
What do I need to add, I haven't a clue how to do this??
Thanks in advance
Dave
I have an Pages Attribute I created called price_reduced.
I've added this to a page and use the following code to write a div in my page:
This works great, but I also have a page list and I want to get the attribute of the child pages in that list and write out a div in my list.
Im using page list teasers add-on and my code for my list looks like this so far:
<div class="ccm-page-list-description"> <div class="veh-titles"> <h3 class="ccm-page-list-title"><a <?php echo $target?>href="<?php echo $nh->getLinkToCollection($cobj)?>"><?php echo $title?></a></h3></div> <?php $plth->output_page_blocks($cobj, $excerptBlocks, $truncateChars); ?> <a class="btn-details" href="<?php echo $nh->getLinkToCollection($cobj)?>">">View Full Details</a> </div>
What do I need to add, I haven't a clue how to do this??
Thanks in advance
Dave
Thanks for the reply John.
Can you give me a bit of syntax re the PHP solution, I'm a complete php n00b really.
I think I will try out Magic Data as well to see how that works :)
Can you give me a bit of syntax re the PHP solution, I'm a complete php n00b really.
I think I will try out Magic Data as well to see how that works :)
You need to create a new custom_teasers template copied from the existing page list teasers template.
It contains a loop that iterates through the listed pages.
Within each iteration of the loop, there is a page object upon which you can add the code you already have to get the attribute.
It contains a loop that iterates through the listed pages.
Within each iteration of the loop, there is a page object upon which you can add the code you already have to get the attribute.
Got it working, thank you very much Jon!! :)
To avoid php, this is a typical application for Magic Data. (Magic Data has a Page List teasers template.) You can embed a suitable magic data token in the text of the page that gets pulled into the teaser. Something like:
[% ORIGINAL_PAGE ATTRIBUTE "price_reduced" END_ON_NULL '<div class="price_reduced"></div>' %]
Then assign the original content block and teaser block magic data templates.
What this does:
ORIGINAL_PAGE - in a list, gets the listed page ID, else gets the current page ID.
ATTRIBUTE "price_reduced" - gets the value of the attribute for the page.
END_ON_NULL - skips if the attribute is false
'<div .... etc' - returned if the attribute is true