Posts by dosa

    My blog search results are not really working. Here's what I have setup:


    1. The search page:

    PHP
    1. <?php
    2. perch_content_search(perch_get('q'), [
    3. 'apps' => ['PerchBlog'],
    4. 'sort' => 'postDateTime',
    5. 'count' => '9',
    6. 'template'=>'search-result.html',
    7. ]);
    8. ?>

    2. The "search-result.html" template referenced above is:

    3. The "blog_search_result.php" is:


    With all that, the results looks as the should style-wise, but even when the results show a total number of 100 for example, I'm only seeing one single result. The pagination is working. But it's as if I added a 'count' filter, but I didn't. What's missing here?


    Does anyone know why a particular author wouldn't show on a filtered page like this:

    PHP
    1. <?php perch_blog_custom([
    2. 'sort' => 'postDateTime',
    3. 'count' => '9',
    4. 'template' => 'blog/post_in_column.html',
    5. 'sort-order' => 'DESC',
    6. 'filter' => 'authorFamilyName',
    7. 'match'=>'eq',
    8. 'value'=>'Smith',
    9. 'paginate' => true,
    10. ]); ?>


    I have many pages just like this one, with different author names instead of "Smith" and they all work fine, showing the articles from that author. I double checked the author details, making sure the "Smith" name is correct, no spaces or anything. I also opened a post from the author, changed it to another author, then switch it back to him. Still nothing.


    What other issues would stop an author's filtered page from showing posts?

    Success! That was the missing piece. Previous I had no results with....


    PHP
    1. <?php perch_category('blog/' . $categorySlug, ['template'=> 'category_title.html']); ?>

    But when adding....


    Code
    1. $categorySlug = perch_get('categorySlug');

    It finally makes the connection....

    PHP
    1. <?php $categorySlug = perch_get('categorySlug');perch_category('blog/' . $categorySlug, ['template'=> 'category_title.html']); ?>

    Thank you both JordinB and hus_hmd for all the help! I hope this last post helps someone make the same edit.

    hi JordinB (and maybe help from hus_hmd ) .....


    I have picked this issue back up again and I'm not seeing a solution. What confuses me is that the page already has Category filtering working just fine....



    So with that, shouldn't I be able to pull the name of the category it's displaying? I want to add it to the title of the page so it's clear what the user is filtering/viewing.


    Code
    1. <div class="header-text">NAME-OF-THE-CATEGORY-TITLE Articles</div>

    hus_hmd - wondering how I can make a slight change here.


    The first page has 13 posts showing - the "Featured" post and the remaining posts. But when you paginate, I'd like to showing 12 stories on the remaining pages since the spacing for 13 stories doesn't make sense on the remaining paginated pages and doesn't layout evenly.


    So is there a way to change the "count" for pages that aren't the first page?


    Again the code.


    post_in_featured_list.html


    And the display content:

    Code
    1. perch_blog_custom([
    2. 'count' => 13,
    3. 'sort' => 'postDateTime',
    4. 'template' => 'blog/post_featured_list.html',
    5. 'sort-order' => 'DESC',
    6. 'paginate' => true,
    7. 'section' => 'blog',

    I've got about 25 categories in a set called 'blog'. To display them along side a list of blog posts as "Categories" I'm doing this:

    PHP
    1. <?php
    2. perch_categories([
    3. 'count' => '12',
    4. 'set' => 'blog',
    5. ]);
    6. ?>

    Looks good on page 1, I only want to show the first 12. But then on the subsequent pages the rest of the tag show and after a few more pages no tag show. How do I show the same categories on all the paginated pages too.

    With debug on, I can see the template. I see the catSlug is correct, but that's not because of the line above. When I add it in, debug shows:


    SQL
    1. SELECT setID FROM cms1_category_sets WHERE setSlug='' LIMIT 1
    2. [nil]SELECT main.* FROM cms1_categories main WHERE 1=1 AND (catPath='blog/') ORDER BY catTreePosition ASC
    3. Using template: /templates/categories/category_title.html
    4. [0]SELECT setID FROM cms1_category_sets WHERE setSlug='' LIMIT 1
    5. [nil]SELECT main.* FROM cms1_categories main WHERE 1=1 AND (catPath='/') ORDER BY catTreePosition ASC


    The categories do live in the /blog/ path, so why isn't it working? Should blog/ be switched to newsroom/category/ ?



    The category_title.html:

    Code
    1. <perch:category id="catTitle" />

    Ok, "catSlug" did it for the busted link. Thanks for the show:all tip - I always forget that one.


    For the Category page - I just want to show the current Category the user is on. I see the options for perch_category, but my code isn't getting there. Is there a snippet to show the current Category 'catTitle'?

    Another question in displaying the Categories. In categories/category.html I have:


    Code
    1. <!-- Category Tag -->
    2. <perch:category id="catSlug" type="slug" for="catTitle" suppress="true" />
    3. <a href="/newsroom/category/<perch:category id="catPath" />" class="tag"><perch:category id="catTitle" type="smarttext" label="Title" required="true" /></a>

    But the link is using the real path to the Category, and not just the slug portion....so its using: mysite.com/newsroom/category/blog/the-slug instead of the re-mapped link. Thoughts on how to remove the /blog part of the link?

    Yay! You rock JordinB! Thank you for your diligence. I didn't know the "blog" Category name was hard-coded in Perch. I had renamed it to "newsroom" a while ago. Good to know.


    So now I've got this:


    1. Categories - a Set added called "Blog" with the "blog" slug and added a 'test' tag.


    2. Changed the post.html call for the Categories to:

    Code
    1. <!-- CHOOSE A CATEGORY -->
    2. <perch:categories id="tags" label="Choose Category Tags" order="3" set="Blog" >
    3. <a href="/newsroom/category/<perch:category id="catPath" />" class="tag"><perch:category id="catTitle" /></a>
    4. </perch:categories>

    3. Opened a post, added the tag "test" to it.


    4. Tried mysite.com/newsroom/category/test


    Filter works :) Finally!


    One more question you might know - I'd like to now add a dynamic title for the tag. How do I display the name of the tag from the URL in the page?

    Ah, getting closer. I didn't know that perch_get line was part of it. So the slug wasn't being defined? Now the page is showing up in the right structure when I try some categories, but with no results, even when a category is added to a post.


    Here's the code:



    No results. Use this to add Categories in post.html:

    Code
    1. <!-- CHOOSE A CATEGORY -->
    2. <perch:categories id="tags" label="Choose Category Tags" order="3" set="Tags" >
    3. <a href="/newsroom/category/<perch:category id="catPath" />" class="tag"><perch:category id="catTitle" /></a>
    4. </perch:categories>