Forum

Thread tagged as: Problem, Blog

Related blog posts not working

I've being checking this post and It don't output anything at:

perch_blog_post_categories(perch_get('s'));

and it output Array() at

print_r(perch_blog_post_categories(perch_get('s'), array('skip-template'=>true)));

Debug Message

[1] SELECT * FROM perch2_blog_posts WHERE postStatus='Published' AND postDateTime<='2016-02-28 10:37:00' AND postSlug='probandolo'
[22] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
[1] SELECT * FROM perch2_blog_sections ORDER BY sectionTitle ASC
[1] SELECT * FROM perch2_blogs ORDER BY blogTitle ASC
Using template: /templates/blog/post.html
Using sub-template: /templates/blog/post-form.html
[1] SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM perch2_blog_index idx JOIN perch2_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN perch2_blog_index idx2 ON idx.itemID=idx2.itemID AND idx.itemKey='postID' AND idx2.indexKey='_id' WHERE 1=1 AND ((idx.indexKey='postSlug' AND idx.indexValue='probandolo')) AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey GROUP BY idx.itemID, idx2.indexValue ) as tbl WHERE (postStatus='Published' AND postDateTime<='2016-02-28 10:37:00' ) GROUP BY itemID, sortval ORDER BY sortval ASC LIMIT 0, 10
[1] SELECT FOUND_ROWS() AS `count`
[1] Using template: /templates/blog/slugblog.html
[3] SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/viaje.php' OR regionPage='*' ORDER BY regionPage DESC
[1] SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM perch2_blog_index idx JOIN perch2_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN perch2_blog_index idx2 ON idx.itemID=idx2.itemID AND idx.itemKey='postID' AND idx2.indexKey='_id' WHERE 1=1 AND ((idx.indexKey='postSlug' AND idx.indexValue='probandolo')) AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey GROUP BY idx.itemID, idx2.indexValue ) as tbl WHERE (postStatus='Published' AND postDateTime<='2016-02-28 10:37:00' ) GROUP BY itemID, sortval ORDER BY sortval ASC LIMIT 0, 10
[1] SELECT FOUND_ROWS() AS `count`
[1] Using template: /templates/blog/post.html
[2] Using sub-template: /templates/blog/post-form.html
Fetching from cache: perch_blog_post_categories0de041f4abb7c49c3ee005bf9bbac8e3
Caching: perch_blog_post_categories0de041f4abb7c49c3ee005bf9bbac8e3
Fetching from cache: perch_blog_post_categories9d886013b1e484b3e7fbbda010cb4af4
Cache file not found: perch_blog_post_categories9d886013b1e484b3e7fbbda010cb4af4
[] Using template: /templates/blog/category.html

Summary information

Perch: 2.8.25, PHP: 5.4.4, MySQL: 5.5.25, with PDO
Server OS: Darwin, apache2handler
Installed apps: content (2.8.25), assets (2.8.25), categories (2.8.25), perch_blog (5.0), perch_forms (1.8.3)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_forms', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /Applications/MAMP/htdocs/eurovacaciones.es/perch
PERCH_CORE: /Applications/MAMP/htdocs/eurovacaciones.es/perch/core
PERCH_RESFILEPATH: /Applications/MAMP/htdocs/eurovacaciones.es/perch/resources
Image manipulation: GD
PHP limits: Max upload 32M, Max POST 32M, Memory: 64M, Total max file upload: 32M
F1: dc1fef2ad0fcd9f943c02ebb43d85dbc
Resource folder writeable: Yes
HTTP_HOST: eurovacaciones:8888
DOCUMENT_ROOT: /Applications/MAMP/htdocs/eurovacaciones.es
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Raul Serrano

Raul Serrano 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

What's the value of s on your query string?

Drew, you mean in the url of a post?

s={postSlug}
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes - you're using perch_get('s').

what do you want me to do Drew?

Drew McLellan

Drew McLellan 2638 points
Perch Support

From the errors you showed me, there's clearly some sort of cache issue. So try disabling the cache, either in the options or by putting your site into development mode (which would be a good idea anyway, since you're developing).

Now I am running on development mode. Clean cache and this are Debug Message

Time    Δ   Debug Message
0.0262  0   [1] SELECT u.*, r.* FROM perch2_users u, perch2_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='b0266e0fe88c5b994917111f8b2015d7' LIMIT 1
0.0268  0.0006  UPDATE perch2_users SET userHash='b2625ad3bc8c2993bc326d2de946da43' WHERE userID='1'
0.0271  0.0003  [38] SELECT p.privKey FROM perch2_user_privileges p
0.0286  0.0015  [22] SELECT * FROM (SELECT DISTINCT settingID, settingValue, userID FROM perch2_settings WHERE userID=1 OR userID=0 ORDER BY userID DESC) AS settings GROUP BY settingID, settingValue, userID
0.042   0.0134  [1] SELECT * FROM perch2_blogs ORDER BY blogTitle ASC
0.0446  0.0026  [1] SELECT * FROM perch2_blogs WHERE blogID=1 LIMIT 1
0.0458  0.0012  [nil] SELECT * FROM perch2_categories c, perch2_category_sets s WHERE c.setID=s.setID AND s.setSlug='blog' ORDER BY catTreePosition ASC
0.0481  0.0023  [1] SELECT * FROM perch2_blog_sections WHERE blogID=1 ORDER BY sectionTitle ASC
0.0485  0.0004  [1] SELECT SQL_CALC_FOUND_ROWS DISTINCT * FROM perch2_blog_posts WHERE blogID=1 ORDER BY postDateTime DESC LIMIT 0, 15
0.0488  0.0002  [1] SELECT FOUND_ROWS() AS count
0.0551  0.0063  [0] SELECT COUNT(*) FROM perch2_blog_comments WHERE commentStatus='PENDING'
0.0595  0.0044  Queries: 12
0.0596  0.0001  Memory: 2.4469

related posts still not showing Drew... This are my categories on post.html

<perch:categories id="pais" label="Pais" set="paises" required="true" />
<perch:categories id="tipoviaje" label="Tipo de viaje" set="tipos" required="true" help="Seleccionar también la categoría genérica Circuitos si se selecciona Circuitos en tren o Circuitos en bus." />
Drew McLellan

Drew McLellan 2638 points
Perch Support

From that it doesn't look like you have any categories in the set blog. How many are there?

I created two different sets outside blog. How can I use those sets instead of blog one?

Drew McLellan

Drew McLellan 2638 points
Perch Support

What ID does your categories field have?

I use two kind of categories

id="pais"
id="tipoviaje"
Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, in that case the built in Blog category functions aren't going to help you in the current version. You'll need to use the standard Categories app functions.

Sorry but I don't get it Drew. Can you explain me that?

Thanks for your time. Support is awesome

Drew McLellan

Drew McLellan 2638 points
Perch Support

I don't have a solution for you, I'm afraid.

Then what it means...

Drew McLellan said: You'll need to use the standard Categories app functions.

Drew McLellan

Drew McLellan 2638 points
Perch Support