Forum

Thread tagged as: Question, Problem

Categories missing and new ones not displaying

Hi,

Just when I thought this was all done!

I noticed that only two of my categories are showing in the blog out of 4 and when I go to the admin to check which category fields are checked fo blog posts I no longer have the "category radio boxes" option to tick from just an empty text box. I'm guessing I've broken something although I can't think what as I've not changed anything category related.

The only thing I did earlier was to try to get blog comments to display in the opposite order and changed the post.php with the following but I can't imagine this did it??

Help much appreciated.... I'm so glad I don't do this for a living any more!! Driven me mad the past week and just want this done.... Sorry very stressed as I was hoping to go out with the wife later :-(

    <?php 
perch_blog_post_comments(perch_get('s'), array(
     'template' => 'comment.html',
));
    ?>    
Rob Hawkins

Rob Hawkins 0 points

  • 7 years ago

I've just tried deleting the exisitng BLOG set and adding new categories and now when I look at the site side bar the categories are not shown at all.

I'm really confused as to what has happened here.

Cheers

Rob

Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you show me your template?

Sorry Drew, which template do you need?

Is that the post.html one?

Please bare with me - very stressed and just would like to get this resolved quickly so I can finish this job that I wish I'd never started.

Here's my post.php file with the sidebar that contains the category navigation

<div id="home_text" class="group">

<!--  change cols2-nav-right to cols2-nav-left if you want the sidebar on the left -->
<div class="wrapper cols2-nav-right">

<nav class="sidebar">

        <!-- The following functions are different ways to display archives. You can use any or all of these. 

        All of these functions can take a parameter of a template to overwrite the default template, for example:

        perch_blog_categories('my_template.html');

        --> 
        <!--  By category listing -->
        <?php perch_blog_categories(); ?>
        <!--  By tag -->
        <!--<?php perch_blog_tags(); ?> -->
        <!--  By year -->
        <!-- <?php perch_blog_date_archive_years(); ?> -->
        <!--  By year and then month - can take parameters for two templates. The first displays the years and the second the months see the default templates for examples -->
        <!-- <?php perch_blog_date_archive_months(); ?> -->
    </nav>


    <div class="primary-content">


        <div class="post">
            <?php perch_blog_post(perch_get('s')); ?>

            <?php perch_blog_author_for_post(perch_get('s')); ?>

            <div class="meta">

                <!--<div class="cats">
                    <?php perch_blog_post_categories(perch_get('s')); ?>
                </div> -->

                <div class="tags">
                    <?php perch_blog_post_tags(perch_get('s')); ?>
                </div>
            </div>

            <?php perch_blog_post_comments(perch_get('s')); ?>

            <?php perch_blog_post_comment_form(perch_get('s')); ?>

        </div>
    </div>

        </div> 

and here's the post.html template

<article class="h-entry">
<h1>
    <a href="<perch:blog id="postURL" type="hidden" />" rel="bookmark" class="p-name">
        <perch:blog id="postTitle" type="text" label="Title" required="true" size="xl autowidth" order="1" />
    </a>
</h1>
<p class="meta">
    <time class="dt-published" datetime="<perch:blog id="postDateTime" type="date" label="Date" time="true" format="Y-m-d H:i:s" divider-before="Meta information" />">
        <perch:blog id="postDateTime" type="date" time="true" format="%d %B %Y" /> 
    </time>
    <perch:if exists="authorGivenName">
         <span class="p-author h-card"><perch:blog id="authorGivenName" type="hidden" /> <perch:blog id="authorFamilyName" type="hidden" /></span>
    </perch:if>


</p>
<perch:if exists="image">
    <div>
        <img src="<perch:blog id="image" type="image" crop="true" label="Image" order="4" />" alt="<perch:blog id="postTitle" />" />
    </div>
</perch:if>

<div class="description e-content">
    <perch:blog id="postDescHTML" type="textarea" label="Post" order="2" editor="markitup" markdown="true" size="xxl autowidth" required="true" />
</div>

</article>

<h2 class="social-share">Share if others could benefit</h3> <!-- Buttons start here. Copy this ul to your document. --> <ul class="rrssb-buttons clearfix">

            <li class="rrssb-twitter">
                    <!-- Replace href with your Meta and URL information  -->



                    <a class="popup" href="https://twitter.com/home?status=<perch:blog id="postTitle" />:- %20https://www.colconquerors.com<perch:blog id="postURL" urlencode="true"/>">

                        <span class="rrssb-icon">
                            <svg version="1.1" id="Layer_1" xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink" x="0px" y="0px"
                                 width="28px" height="28px" viewBox="0 0 28 28" enable-background="new 0 0 28 28" xml:space="preserve">
                            <path d="M24.253,8.756C24.689,17.08,18.297,24.182,9.97,24.62c-3.122,0.162-6.219-0.646-8.861-2.32
                                c2.703,0.179,5.376-0.648,7.508-2.321c-2.072-0.247-3.818-1.661-4.489-3.638c0.801,0.128,1.62,0.076,2.399-0.155
                                C4.045,15.72,2.215,13.6,2.115,11.077c0.688,0.275,1.426,0.407,2.168,0.386c-2.135-1.65-2.729-4.621-1.394-6.965
                                C5.575,7.816,9.54,9.84,13.803,10.071c-0.842-2.739,0.694-5.64,3.434-6.482c2.018-0.623,4.212,0.044,5.546,1.683
                                c1.186-0.213,2.318-0.662,3.329-1.317c-0.385,1.256-1.247,2.312-2.399,2.942c1.048-0.106,2.069-0.394,3.019-0.851
                                C26.275,7.229,25.39,8.196,24.253,8.756z"/>
                            </svg>
                       </span>
                        <span class="rrssb-text">twitter</span>

                    </a>
                </li>


                <li class="rrssb-facebook">
                    <!-- Replace with your URL. For best results, make sure you page has the proper FB Open Graph tags in header:
                    https://developers.facebook.com/docs/opengraph/howtos/maximizing-distribution-media-content/ -->
                    <a href="https://www.facebook.com/sharer/sharer.php?u=https://www.colconquerors.com<perch:blog id="postURL" urlencode="true"/>" class="popup">
                        <span class="rrssb-icon">
                            <svg version="1.1" id="Layer_1" xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink" x="0px" y="0px" width="28px" height="28px" viewBox="0 0 28 28" enable-background="new 0 0 28 28" xml:space="preserve">
                                <path d="M27.825,4.783c0-2.427-2.182-4.608-4.608-4.608H4.783c-2.422,0-4.608,2.182-4.608,4.608v18.434
                                    c0,2.427,2.181,4.608,4.608,4.608H14V17.379h-3.379v-4.608H14v-1.795c0-3.089,2.335-5.885,5.192-5.885h3.718v4.608h-3.726
                                    c-0.408,0-0.884,0.492-0.884,1.236v1.836h4.609v4.608h-4.609v10.446h4.916c2.422,0,4.608-2.188,4.608-4.608V4.783z"/>
                            </svg>
                        </span>
                        <span class="rrssb-text">facebook</span>
                    </a>
                </li>

                <li class="rrssb-linkedin">
                    <!-- Replace href with your meta and URL information -->
                    <a class="popup" href="https://www.linkedin.com/shareArticle?mini=true&amp;url=https://www.colconquerors.com<perch:blog id="postURL" urlencode="true"/>">
                        <span class="rrssb-icon">
                            <svg version="1.1" id="Layer_1" xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink" x="0px" y="0px" width="28px" height="28px" viewBox="0 0 28 28" enable-background="new 0 0 28 28" xml:space="preserve">
                                <path d="M25.424,15.887v8.447h-4.896v-7.882c0-1.979-0.709-3.331-2.48-3.331c-1.354,0-2.158,0.911-2.514,1.803
                                    c-0.129,0.315-0.162,0.753-0.162,1.194v8.216h-4.899c0,0,0.066-13.349,0-14.731h4.899v2.088c-0.01,0.016-0.023,0.032-0.033,0.048
                                    h0.033V11.69c0.65-1.002,1.812-2.435,4.414-2.435C23.008,9.254,25.424,11.361,25.424,15.887z M5.348,2.501
                                    c-1.676,0-2.772,1.092-2.772,2.539c0,1.421,1.066,2.538,2.717,2.546h0.032c1.709,0,2.771-1.132,2.771-2.546
                                    C8.054,3.593,7.019,2.501,5.343,2.501H5.348z M2.867,24.334h4.897V9.603H2.867V24.334z"/>
                            </svg>
                        </span>
                        <span class="rrssb-text">linkedin</span>
                    </a>
                </li>




                <li class="rrssb-googleplus">
                    <!-- Replace href with your meta and URL information.  -->
                    <a class="popup" href="https://plus.google.com/share?url=https://www.colconquerors.com<perch:blog id="postURL" urlencode="true"/>" >
                        <span class="rrssb-icon">
                            <svg version="1.1" id="Layer_1" xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink" x="0px" y="0px" width="28px" height="28px" viewBox="0 0 28 28" enable-background="new 0 0 28 28" xml:space="preserve">
                                <g>
                                    <g>
                                        <path d="M14.703,15.854l-1.219-0.948c-0.372-0.308-0.88-0.715-0.88-1.459c0-0.748,0.508-1.223,0.95-1.663
                                            c1.42-1.119,2.839-2.309,2.839-4.817c0-2.58-1.621-3.937-2.399-4.581h2.097l2.202-1.383h-6.67c-1.83,0-4.467,0.433-6.398,2.027
                                            C3.768,4.287,3.059,6.018,3.059,7.576c0,2.634,2.022,5.328,5.604,5.328c0.339,0,0.71-0.033,1.083-0.068
                                            c-0.167,0.408-0.336,0.748-0.336,1.324c0,1.04,0.551,1.685,1.011,2.297c-1.524,0.104-4.37,0.273-6.467,1.562
                                            c-1.998,1.188-2.605,2.916-2.605,4.137c0,2.512,2.358,4.84,7.289,4.84c5.822,0,8.904-3.223,8.904-6.41
                                            c0.008-2.327-1.359-3.489-2.829-4.731H14.703z M10.269,11.951c-2.912,0-4.231-3.765-4.231-6.037c0-0.884,0.168-1.797,0.744-2.511
                                            c0.543-0.679,1.489-1.12,2.372-1.12c2.807,0,4.256,3.798,4.256,6.242c0,0.612-0.067,1.694-0.845,2.478
                                            c-0.537,0.55-1.438,0.948-2.295,0.951V11.951z M10.302,25.609c-3.621,0-5.957-1.732-5.957-4.142c0-2.408,2.165-3.223,2.911-3.492
                                            c1.421-0.479,3.25-0.545,3.555-0.545c0.338,0,0.52,0,0.766,0.034c2.574,1.838,3.706,2.757,3.706,4.479
                                            c-0.002,2.073-1.736,3.665-4.982,3.649L10.302,25.609z"/>
                                        <polygon points="23.254,11.89 23.254,8.521 21.569,8.521 21.569,11.89 18.202,11.89 18.202,13.604 21.569,13.604 21.569,17.004
                                            23.254,17.004 23.254,13.604 26.653,13.604 26.653,11.89      "/>
                                    </g>
                                </g>
                            </svg>
                        </span>
                        <span class="rrssb-text">google+</span>
                    </a>
                </li>

            </ul>
            <!-- Buttons end here -->

<perch:blog id="excerpt" type="textarea" label="Excerpt" markdown="true" order="3" suppress="true" size="s" /> <perch:blog id="image" type="image" width="50" height="50" crop="true" suppress="true" />

Drew,

Apologies in a BIG way, cut and paste error on my part. I think I used undo a few too many times when I made a mistake and this must have got cut.

I'll crawl back into my hole now!

Thanks for the help and quality (fast) support again.

I owe you a beer or two.

Cheers

Rob

<perch:categories id="categories" set="blog" label="Categories" display-as="checkboxes">
        <a href="archive.php?cat=<perch:category id="catSlug" type="slug" />" class="p-category">
            <perch:category id="catTitle" type="text" />
        </a>
    </perch:categories>

I've just tried to add a new blog post and I'm now getting the following error:

"Sorry, that post could not be updated."

I can edit and make changes to existing posts but it appears I can't add new ones, why would this be?

I notice that on the form in between the "categories" and "tags" fields I still have this empty field, could it be this? Here's the output code from the admin the blank box seems to be the middle of the 3 "postURL"

<div class="field ">

<label class="" for="perch_categories">Categories</label> <fieldset class="checkboxes fieldtype uni-col"> </div>

<div class="field "> <label class="" for="perch_postURL"></label> <input id="perch_postURL" class="text " type="text" value="" name="perch_postURL"> </div>

<div class="field "> <label class="" for="postTags">Tags</label> <input id="postTags" class="text " type="text" value="1111" name="postTags"> <span class="hint">Separate with commas</span> </div>

Drew McLellan

Drew McLellan 2638 points
Perch Support

Turn on debug. Submit the form. Do you get any errors?

Getting beyond me now... How do I turn on debug?

Drew McLellan

Drew McLellan 2638 points
Perch Support

done it!

I get this error

0.0644 0.0015 Invalid query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'postURL' in 'field list'

Drew McLellan

Drew McLellan 2638 points
Perch Support

Where you have

<perch:blog id="postURL" urlencode="true"/>

change it to

<perch:blog id="postURL" urlencode="true" type="hidden" />

:-) Thanks, this goes to show what happens when you don't touch any of this for best part of 18 months and then come back to work on a personal project!

Just to save me being a total pain in the a**** the ONLY thing I have outstanding is to get the post comments to display latest first as opposed to latest at the bottom. How do I change this?

do I add this to my post.php

 <?php 
 perch_blog_post_comments(perch_get('s'), array(
 'sort-order' => 'DESC',
));
 ?>

Reverse order works thanks....

Drew McLellan

Drew McLellan 2638 points
Perch Support

You need to set sort as well as sort-order.

Hi Drew,

The docs say:

sort The ID of the field to sort by (detault: commentDateTime)

So do I need to add anything to the code in my previous post given the default looks to be the "commentDateTime" field?

Things might have changed so happy to take advice especially this week!

Cheers

Rob

Drew McLellan

Drew McLellan 2638 points
Perch Support

No, that's not changed, but you do need to set it if you want to use sort-order.

Hi Drew,

The only reason I'm using sort-order is to ensure latest comments appear at the top of the list. Prior to sort-order being added the oldest appeared first.

So do I need to add like this?

<?php 
 perch_blog_post_comments(perch_get('s'), array(
 'sort' => 'commentDateTime',
 'sort-order' => 'DESC',
));
 ?>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Is that not working?

It's working without the 'sort' entry so wanted to be clear why I needed it in addition to the 'sort-order'...