Category on top...
8 posts by 4 authors in: Forums > CMS Builder
Last Post: November 16, 2016 (RSS)
By osga - November 10, 2016
We would like to place the name of the category corresponding to the article shown on the srticle page at the top of the page.
Referring to this page, we would like to replace the title "NEWS" at the top, with the name of the category of the article shown:
I've tried replacinc "NEWS" with code like <?php echo htmlencode($categoryRecord['parentNum']) ?>
and others, but there must be something at the top of the article template php that im missing?
By ross - November 10, 2016
Hi there.
Thanks for posting.
What I think you'll need is something like this:
<?php echo htmlencode($articleRecord['category:label']) ?>
Notice how I am using the "articleRecord" array instead of the "categoryRecord" array. Your article record array might have a different name so make sure to update my code example.
Let me know if this works for you.
Thanks!
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com
Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/
By osga - November 10, 2016
that one gave me an error..
i can throw these in <?php echo $articlesRecord['art_field1'] ?>, and they work, just nothing using "Category" (so far)
By ross - November 11, 2016
Could you attach a copy of your page to a reply? I'd like to review your code.
Please don't just paste all the code into your reply.
Thanks.
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com
Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/
Hi Osga,
Looking at the article_blank.php file, it seems the category is stored a in a field called categoryNum. So one of these values should work:
<?php echo htmlEncode($articlesRecord['categoryNum:label']); ?>
<?php echo htmlEncode($articlesRecord['categoryNum:text']); ?>
<?php echo htmlEncode($articlesRecord['categoryNum']); ?>
I would try each of the statements above from top to bottom, I think the first one will be the correct one.
Thanks,
Greg
PHP Programmer - interactivetools.com
By osga - November 16, 2016 - edited: November 16, 2016
Excellent Greg, thank you! The top one worked perfectly! Cheers!
In the same vein... is there a way to hide the parent category in the string? So instead of seeing "Sport: Football: NFL" it would be just "NFL"? not a dealbreaker, but I thought I would ask...
By Damon - November 16, 2016
Hi,
Add this CMS Builder function to the page to display all the available variables that you can use:
<?php showme($articlesRecord); ?>
Damon Edis - interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/