Posts by JordinB

    From that sql it doest look like the concatenation of the category slug is working being passed to the perch_category function.


    to save some time guessing, can you please post your php file from the beginning up to that perch_category function call? If you don’t want to post it, you can email it to me:


    jbrown [at] cognetif dot com

    since you just have the slug, you'll need to build the category path, create simple template and do something like:


    template: category_title.html


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

    which will simply just render the title... thats it.


    you render it with:


    Code
    1. perch_category('blog/' . $categorySlug, ['template'=> 'category_title.html']);



    Alternatively from your page (say it was in a h1 tag or something):


    Code
    1. echo "<h1>" . perch_category('blog/'.$categorySlug, ['skip-template'=>true], true)['catTitle'] . "</h1>";



    but not sure if perch_category is going to return a 1 item indexed array...probably, i can't remember ... so in that case it would be:


    Code
    1. echo "<h1>" . perch_category('blog/'.$categorySlug, ['skip-template'=>true], true)[0]['catTitle'] . "</h1>";

    Note the [0] to specify the first item returned.

    Quote

    i'd like to now add a dynamic title for the tag.

    If i'm understanding, you'd like to display the category name that matches the slug "tag" ?

    To do that you need to get the category from perch_category. Then either render a specific template or simply return the data and echo it in php.



    Quote

    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?


    Don't use the 'catPath', rather use the 'catSlug' in the url. Don't forget that you can use <perch:showall> in a template to see all the variables and values available to you within the template.

    no, the perch code specifically looks for categories under a set called : blog.


    Here is the code that does that:

    So if you pass 'category' to the options, it loops over each category and will prepend 'blog' to the passed category. so if you pass: 'awards' from the query string through the 'category' option, the perch code will transform that to: blog/awards. So that path needs to exist in your categories.

    you're pulling in something like this on the category page ?


    turn on perch debug, you will see it matching routes and detect which route is matched.


    Its normal that tags/awards won't work because the forward slash is not a part of a valid slug.


    i am surprised a little that the newsroom/category/awards is not being directed to that page though.


    Have you tried with a starting slash in the route like: /newsroom/category/[slug:cat] I wonder if its because its a subpage.

    yeah, so you really don't need blocks for this. you're choice is either a multi-item region that you can edit in a list/detail type of cms page, or create 1 single region and add a repeater for each image.


    Either way you can drag and drop the items to reorder them. and your template will basically be the same or similar to :


    Code
    1. <!-- image_link.html -->
    2. <a href="#<perch:content id="image" type="image" label="Image" />"><!-- Link to your fullsize lightbox image -->
    3. <img src="<perch:content id="image" type="image" crop width="200" height="200" />" alt="<perch:content id="caption" type="text" label="Image Caption" />" /></a>

    if you're using the multi-item method, the template of the region would be 'image_link.html'


    if you're using the repeater you could do :

    ok,


    Perch needs to know that /about/newsroom/category/tags/rewards is the same page as say /about/newsroom/category/tags/prizes. So the category page needs to have a url rule setup to parse that information so that when Perch sees the url, it knows which page is supposed to be rendered and what the category is in the url:


    Here is my blog archive page setup:



    Note that i have a bilingual site, so the url patterns are matching french or english.. but thats not the important part here, your urls won't have that.


    you can see that it has 2 url patterns:


    1. /en/blog/archive/2019 which will populate a variable called $year with 2019 and be available on the archive.php page

    2. /en/blog/archive/some-category-slug which will populate a variable called $categorySlug with the value some-category-slug and that will be available on the archive.php page.


    So when on the archive.php page, if there is data in $year, it renders the blog posts by year, if there is data in $categorySlug, it renders the blog posts by category.