Forum
Blog Category Custom Field
Hi guys,
I've added:
<perch:blog id="categoryColour" type="text" label="Colour" required="true" help="Format: #HEX" />
to the category.html blog template and now need to get that value within the blog post, i tried:
<perch:blog id="categoryColour" type="hidden" />
but that doesn't do anything, where am i going wrong!? or is that not possible?!
Thanks
That's a field belonging to the category, not the post.
If you want to show it along with the post you'll need to pass it into the template.
ok cool, gave it a try and managed to nail it! For anyone that comes across this:
<?php $cat_colour = (perch_blog_post_categories(perch_get('s'), 'category_colour.html', true)); PerchSystem::set_var('categoryColour', $cat_colour); perch_blog_post(perch_get('s')); ?>
The above doesn't work on the blog list (post_in_list.html) do i just need to tweak the code or something entirely different?!
You need to handle it in the
each
callbacksomething like this?
The above doesn't work and just kills the page and nothing loads!
Check your PHP error log for the message.
ahh there was a missing ')' - page loads as normal but the colour doesn't show:
updated code:
Which version of Blog are you on?
blog version 4.1
That should work then. Hmm.
You're using
categoryColour
inpost_in_list.html
?yep
Oh, hold on. This:
should be:
brilliant all working! Thanks :)