Forum

Thread tagged as: Configuration, Blog

Recent post function not displaying any content

Hi,

I've recently started working with perch and I'm currently building a website for a client with it. My dilemma is that while I was trying to set up the blog functionality on the website I wasn't able to display any of the blog posts through the perch_blog_recent_posts() function.

If I try to access the individual blog posts they display and populate all the content correctly in the right elements but it seems that the problem only exists while trying to display all the recent posts.

Has anyone else had this problem and if so, how were you able to solve it?

The development is being done locally through XAMP and I was also wondering whether that might have any effect?

Here's my debug log form the SELECT u.*, r.* FROM perch3_users u, perch3_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='99889a69c2eee4c738988ba7a8b6864a' LIMIT 1 UPDATE perch3_users SET userHash='351e656db73781809d376637bb34b397' WHERE userID='1' [13] SELECT settingID, settingValue, userID FROM perch3_settings WHERE userID=1 OR userID=0 ORDER BY userID ASC [7] SELECT itemValue FROM perch3_menu_items WHERE itemType='app' [nil] SELECT *, REPLACE(pagePath, '/index.php', '') as sortPath FROM perch3_pages WHERE pageNew=1 ORDER BY LENGTH(sortPath)-LENGTH(REPLACE(sortPath, '/', '')) ASC [1] SELECT p.*, (SELECT COUNT() FROM perch3_pages WHERE pageParentID=p.pageID) AS subpages FROM perch3_pages p WHERE p.pageParentID IN (0) ORDER BY p.pageTreePosition ASC [2] SELECT * FROM perch3_content_regions ORDER BY regionOrder ASC [nil] SELECT * FROM perch3_content_regions WHERE regionPage='' ORDER BY regionKey ASC [1] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=0 ORDER BY itemOrder ASC LIMIT 0, 1 [2] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=1 ORDER BY mi.itemOrder ASC [1] SELECT itemTitle FROM perch3_menu_items WHERE itemType='app' AND itemValue='content' LIMIT 1 [1] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=0 ORDER BY itemOrder ASC LIMIT 1, 10 [2] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=2 ORDER BY mi.itemOrder ASC File: \core\apps\content\modes\list.post.php [2] SELECT DISTINCT regionTemplate FROM perch3_content_regions ORDER BY regionTemplate ASC

Johan Erlandsson

Johan Erlandsson 0 points

  • 3 years ago
Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hello Johan,

Could you share your code with us?

By the way, this looks like the debug log from the control panel. Can you share the debug message from the page you're having issues on?

The development is being done locally through XAMP and I was also wondering whether that might have any effect?

I use XAMPP too. It shouldn't be the problem.

Hey Hussein,

Thanks for taking the time to answer my question.

Here's the debug from my blog page

SELECT u.*, r.* FROM perch3_users u, perch3_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='8ce1736980f42dd9a39d4376bede544c' LIMIT 1
UPDATE perch3_users SET userHash='1012a296c7682375493533d72fc08e28' WHERE userID='1'
[13] SELECT settingID, settingValue, userID FROM perch3_settings WHERE userID=1 OR userID=0 ORDER BY userID ASC
[7] SELECT itemValue FROM perch3_menu_items WHERE itemType='app'
[0] SELECT COUNT(*) FROM perch3_blog_comments WHERE commentStatus='PENDING'
[1] SELECT * FROM perch3_blogs ORDER BY blogTitle ASC
[1] SELECT * FROM perch3_blogs ORDER BY blogTitle ASC LIMIT 1
[3] SELECT * FROM perch3_categories c, perch3_category_sets s WHERE c.setID=s.setID AND s.setSlug='blog' ORDER BY catTreePosition ASC
[1] SELECT * FROM perch3_blog_sections WHERE blogID=1 ORDER BY sectionTitle ASC
[2] SELECT SQL_CALC_FOUND_ROWS DISTINCT * FROM perch3_blog_posts WHERE blogID=1 ORDER BY postDateTime DESC LIMIT 0, 15
[1] SELECT FOUND_ROWS() AS count
[1] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=0 ORDER BY itemOrder ASC LIMIT 0, 1
[2] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=1 ORDER BY mi.itemOrder ASC
[1] SELECT itemTitle FROM perch3_menu_items WHERE itemType='app' AND itemValue='perch_blog' LIMIT 1
[1] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=0 ORDER BY itemOrder ASC LIMIT 1, 10
[2] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=2 ORDER BY mi.itemOrder ASC

Here's my code

<?php include('../perch/runtime.php'); ?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Active Fitness Tamworth | Blog</title>
  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link rel="stylesheet" href="../css/style.css">
    <link href="https://fonts.googleapis.com/css?family=Oswald|Playfair+Display+SC:400,900|Trocchi" rel="stylesheet">
    <script src="https://use.fontawesome.com/16097951fd.js"></script>
</head>
<body>

<div class="navbar-wrapper">
        <div class="container-fullwdith">

            <nav class="navbar navbar-inverse navbar-static-top">
                <div class="container">
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed" data-toggle="modal" data-target="#nav-modal" aria-expanded="false" aria-controls="navbar">
                            <span class="sr-only">Toggle navigation</span>
                            <i class="fa fa-bars fa-2x" aria-hidden="true" style="color: white;"></i>
                        </button>
                        <a href="index.html">
                            <div id="logo-img" alt="logo image"></div>
                        </a>
                    </div>
                    <div id="navbar" class="navbar-collapse collapse">
                        <ul class="nav navbar-nav">
                            <li><a href="membership.html">Memberships</a></li>
                            <li class="dropdown">
                              <a data-toggle="dropdown" href="#">Training</a>
                              <ul class="dropdown-menu">
                                <li><a href="classes.html">Classes</a></li>
                                <li><a href="schedule.html">Schedule</a></li>
                                <li><a href="transformation.html">My Transformation</a></li>
                                </ul>
                            </li>
                            <li><a href="about.html">About Us</a></li>
                            <li><a href="contact.html">Contact Us</a></li>
                            <li class="active"><a href="blog.html">Blog</a></li>
                        </ul>
                    </div>
                </div>
        </nav>

    </div>
</div>

<div class="modal fade" id="nav-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-nav-content">
      <div class="modal-nav-body">
        <ul>
        <li><a href="membership.html">Memberships</a></li>
        <li><a href="classes.html">Classes</a></li>
        <li><a href="schedule.html">Schedule</a></li>
        <li><a href="transformation.html">My Transformation</a></li>
        <li><a href="about.html">About Us</a></li>
        <li><a href="contact.html">Contact Us</a></li>
        <li class="active"><a href="blog.html">Blog</a></li>
        </ul>
      </div>
    </div>
  </div>
</div>

<div class="container-fluid">
    <div class="row">
          <div class="hero-image-blog">
              <div class="hero-text-blog">
                  <h1>Blog</h1>
              </div>
          </div>
    </div>
</div>

<div class="container">
  <div class="row"> 
    <div class="posts-listing col-lg-8">
      <div class="row">
        <div class="col-lg-6"> 
          <?php perch_blog_recent_posts(2, true); ?>

        </div>
      </div>
    </div>
  </div>

</div>


<div class="container-fullwdith">
    <footer id="myFooter">
        <div class="container">
            <div class="row">
                <div class="col-sm-3">
                    <h2 class="logo"><a href="#"><img src="../images/aft-logo-sm.png"></a></h2>
                </div>
                <div class="col-sm-2">
                    <h5>Get started</h5>
                    <ul>
                        <li><a href="index.html">Home</a></li>
                        <li><a href="membership.html">Membership</a></li>
                        <li><a href="classes.html">Classes</a></li>
                    </ul>
                </div>
                <div class="col-sm-2">
                    <h5>About us</h5>
                    <ul>
                        <li><a href="contact.html">Contact us</a></li>
                        <li><a href="about.html">About us</a></li>
                    </ul>
                </div>
                <div class="col-sm-2">
                    <h5>Support</h5>
                    <ul>
                        <li><a href="membership.html">FAQ</a></li>
                    </ul>
                </div>
                <div class="col-sm-3">
                    <div class="social-networks">
                        <a href="https://www.facebook.com/ActiveFitnessTamworth/" class="facebook"><i class="fa fa-facebook"></i></a>
                        <a href="https://www.instagram.com/ActiveFitness_Tamworth/" class="google"><i class="fa fa-instagram"></i></a>
                    </div>
                </div>
            </div>
        </div>
        <div class="footer-copyright">
            <p>© 2017 Active Fitness Tamworth </p>
        </div>
    </footer>
</div>
</body>
</html>
Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Remove the second argument from your function call:

perch_blog_recent_posts(2);

If you're interested in what the second argument does, you can check the function's documentation.