Blog App Custom Slugs & URLS

  • Just been trying to get custom blog url / slugs working under the settings tab (Blog post page path & Slug format) using my own perch:blog id's...


    This last post here from Mark Fisher from the old forum outlines the exact issue:


    http://forum.grabaperch.com/fo…ynamic-fields-in-template


    Long story short as Drew mentions:

    Quote

    You should be able to use any IDs from the post.html template in the post slug

    However you currently cannot, the only id's which pull through are:

    Quote

    postID, blogID, postTitle, postSlug, postDateTime, postDescRaw, postDescHTML, postDynamicFields, postTags, postStatus, authorID, sectionID, postCommentCount, postImportID, postLegacyURL, postAllowComments, postTemplate, postMetaTemplate, postIsPublished, image, sectionTitle, SectionSlug, sectionPostCount, sectionDynamicFields, perch_image, blogTitle, blogSlug, setSlug and blogDynamicFields


    Can this be added as a bug / feature request? I appreciate you can work around it in a couple of ways using perch_blog_custom() however to keep the View Post / View Draft buttons working correctly in the control panel you have to hijack / use one of the above, looks like postTags will work for me on this occasion.

  • drewm

    Approved the thread.
  • Thanks Hussein,


    Whilst my previous solution was working, I think I prefer keeping it all within postSlug. Here's my final solution for future reference if anyone needs to composite blog urls from other fields.


    HTML
    1. <perch:blog id="postSector" type="select" label="Sector" options="Aviation|aviation, Rail|rail, Commercial|commercial, Industrial|industrial, Food Industry|food-industry, Highways|highways, Domestic|domestic" allowempty="false" required suppress>
    2. <perch:blog id="postSlugPre" type="slug" for="postTitle" label="URL Slug" suppress editable help="Delete & save to generate new slug from post title">
    3. <perch:blog id="postSlug" type="composite" for="postSector postSlugPre" join="/" suppress>