Forum
Post list on post.html not working
I want to show related posts on post.html page, filtered by current category, but for some reason is not showing anything...
Post.html:
<?php
perch_blog_custom(array(
'count' => 10000,
'template' => 'proyectos.html',
'sort' => 'postDateTime',
'sort-order' => 'DESC',
'category' => perch_get('cat'),
// I also tried this-------> 'category' => 'proyectos/'.perch_get('cat'),
));
?>
template
<li>
<a href='/proyecto.php?s=<perch:blog id="postSlug" />'>
<figure>
<img src='<perch:blog type="image" id="image_portada" label="Imagen portada" width="400" height="400" crop="true" suppress="false" />' alt='<perch:blog id="postTitle" type="text" label="Título (es)" divider-before="Título" required="true" size="xl autowidth" title="true" />' />
<figcaption>
<perch:if id="lang" value="es"><perch:blog id="postTitle" type="text" label="Título (es)" required="true" size="xl autowidth" title="true" /></perch:if>
<perch:if id="lang" value="en"><perch:blog id="postTitle-en" type="text" label="Título (en)" required="true" size="xl autowidth" /></perch:if>
<perch:if id="lang" value="fr"><perch:blog id="postTitle-fr" type="text" label="Título (fr)" required="true" size="xl autowidth" /></perch:if>
</figcaption>
</figure>
</a>
</li>
diagnostic report:
Perch: 3.0.4, PHP: 5.4.4, MySQL: 5.5.25, with PDO
Server OS: Darwin, apache2handler
Installed apps: content (3.0.4), assets (3.0.4), categories (3.0.4), perch_blog (5.5.1)
App runtimes: <?php $apps_list = [ perch_blog, ];
PERCH_LOGINPATH: /perch
PERCH_PATH: /Applications/MAMP/htdocs/optaarquitectos.com/perch
PERCH_CORE: /Applications/MAMP/htdocs/optaarquitectos.com/perch/core
PERCH_RESFILEPATH: /Applications/MAMP/htdocs/optaarquitectos.com/perch/resources
Image manipulation: GD
PHP limits: Max upload 32M, Max POST 32M, Memory: 64M, Total max file upload: 32M
F1: 0c66c2e1f82f9e0b7617b2cb8270f2c7
Resource folder writeable: Yes
HTTP_HOST: opta2:8888
DOCUMENT_ROOT: /Applications/MAMP/htdocs/optaarquitectos.com
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
You can't use PHP functions in an HTML template. If you need the result output within the template, you'll need to get the result out on the page and then pass it in.
Excuse me Drew, i was meaning post.php
I don't get the problem here. I am just making a simple category filtering on post page... hmmm...
Hi Raul, is there a 'cat' value to get in the querystring at this point? There would need to be for that to work.
You'll need to use
perch_blog_post_categories
to get the category(s) from the current post.This helpful article from Clive Walker will help you:
https://www.cvwdesign.com/blog/how-to-show-related-posts-with-perch-blog
Hi Simon, I am using this code
I tried but It didn't work as I adapted:
Going back to your original code, does this work?
No, it doesn't...
what does
output to the page?
It output catslug
Ok, so that's obviously not a category you're after.
Can you show your whole page code now, as I am unsure of what's in there at this point.
Sorry for delay Simon, I've being out for two weeks. Here is the full code