Multiple Blogs Split By Section - Can They Share A Page?

  • I've got a blog with multiple Sections, each section has many stories. We split those Sections up in pages in the website, such as News, Press, Awards, Blog.


    I'm display those sections like this:

    PHP
    1. <?php perch_blog_custom([
    2. 'count' => 12,
    3. 'sort' => 'postDateTime',
    4. 'template' => 'blog/post_in_column_with_blurb.html',
    5. 'sort-order' => 'DESC',
    6. 'paginate' => true,
    7. 'section' => 'press',
    8. ]); ?>


    Notice the Section is set to "press". But what if an article belongs in MULTIPLE sections. A Press article could also belong in an Awards article. Can you apply more than one Section to a particular post?


    This site grew over time and now I realize maybe I should have created multiple Blogs instead, and not one Blog split into sections. Is it too late? Can those posts be moved? For example: Blog has a Section called News with 115 posts ....can I export/import those posts into a new Blog set called News instead? Seems like it would make more sense, but I'm not sure it's worth moving everything. Thoughts?


    PS. In researching this, I see this link is broken @drew - https://docs.grabaperch.com/addons/blog/multiple-blogs/

  • Yes, I'm categorizing them now, but they started as sections from one blog.


    The goal is:


    1. Split each group of postings on their own pages (which I am doing now with sections)


    2. Also to have category pages for different ways to view the articles (also doing that with sections)


    3. But the challenge is to have "tag" style links to a subject, the display all related articles to that category, no matter what the source. Like a dynamic link.


    So in my example above, the News story is always on the News pages, but that same story if it has a Category attached to it (which I have setup in the post.html template already), then it can show up on another page since it's related, but not in the same section. The issue arrises when the sections are split up. So I wonder if separate blogs would make sense.


    On that same note, I am thinking if I do add additional blogs that match the Sections, I can export those Section stories, and re-import them into the new blog tab. Do I have that right?

  • on my site i have a simple blog, there is only 1 section, but each of the articles can be tagged with multiple subjects. At the bottom of each article i have a list of "categories" which groups similar articles together. If you click on the category it goes to a page where all the articles listed are of that category.



    it that what you're looking to achieve ?

  • Shouldn't be. All i'm doing is using categories. The post has a categories checkbox section, so multiple checkboxes for each category, and in the post template, i link the category slug to my archive page. /blog/archive/{categoryslug}. The archive does the following to render the list:


    Code
    1. perch_blog_custom([
    2. 'category' => $categorySlug,
    3. 'cache' => false,
    4. 'template' => 'blog/post_in_list.html',
    5. ]);
  • Hmm, doesn't work yet. I have two Category sets. The one I want to reference is "Tags". How do I define that set? I tried using the slug from the Categories....in this case an example would be: about/newsroom/category/tags/transform


    But I get a 404.


    ...using Runway by the way. Does that change things?

  • Ah, sorry. Yep me too :) Runway all the way.


    I'm saying when I enter the proper URL it doesn't work. I have a page setup called /category (instead of archive) so category/tag/transform doesn't work.


    The only way it's working for me is directly adding the tag string in the "category" option. That means a manual page for each. There are only 10, but seems unnecessary if it can do the linking dynamically.


    PHP
    1. <?php perch_blog_custom([
    2. 'category' => 'tags/awards',
    3. 'cache' => false,
    4. 'count' => 12,
    5. 'sort' => 'postDateTime',
    6. 'template' => 'blog/post_in_column.html',
    7. 'sort-order' => 'DESC',
    8. 'paginate' => true,
    9. ]);
    10. ?>

    ....so this would be the "Awards" tag page. But I'd rather it be dynamic, not hardcoded.

  • ok so your set of categories is a subset of "/tags" ?


    "category/tag/transform" this is the url? is it "transform" that is the category slug?


    you must have a route to parse the category from the url ?


    i need to see more code to understand how you have your category page setup.

  • Yes, the set is /tags


    Yes, the slug is /transform (I used "awards" in my example above, but same idea)


    Not sure what you mean by a "route to parse the category url". Is that something I missed?


    In my post.html I have a category selector, see attached example of "Awards" which has a slug of "tags/awards"


    I want to use a link like: mysite.com/about/newsroom/category/tags/awards ....to display the results.


    I created a page in about/newsroom/category with the code above, then tried the URL and got a 404.


    I then switched the 'category' => $categorySlug to 'category' => 'tags/awards'


    That shows the items just fine, but why doesn't the URL work using the $categorySlug option?

    Images

    • Screen Shot 2020-02-20 at 10.52.50 AM.png
  • 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.

  • Thanks (again) for this. It helped me resolve another issue I was having as you saw on my other post :)


    Though my slug must not be correct for this page as it's still not working.



    And here is the Setting for the slug:


    And when I try mysite.com/newsroom/category/awards I still get the 404. I also tried mysite.com/newsroom/category/tags/awards


    I hope I am close!

  • 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.

  • Interesting. I changed the Route to: newsroom/category/[slug:categorySlug]


    The page is no longer a 404, but it's not filtering anything either. Just showing ALL articles. So the slug must not be connecting, right?


    Does the Set have to be defined as well?

  • you're pulling in something like this on the category 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>
  • The blog app is going to search for your category under a parent "Blog" set by default i believe. so if the parent set of your categories is not Blog, it won't find anything.



    In Perch click on Categories, I believe it needs to be : Blog / Your categories. Not Tags / Your categories