Forum

Thread tagged as: Runway, Question, Blog

Multiple Blog Confusion

Hi There,

I have managed to set-up a Blog using the Blog_App and Runway after following the guidance on your YouTube video.

I now would like to create a new Blog named News.

I have created a new Blog from Blog/Blogs and named it News.

I then created new templates (index, archive and post.php) under the templates/pages/news directory, in the same way as suggested in the Blog Video.

As the News items will have the same naming convention and pattern, I did not change the routing token in runway.php

'routing_tokens' => [
    'blogslug' => '[1-2][0-9]{3}\-[0-9]{2}\-[0-3][0-9]-[a-z0-9\-]+',
],  

With then new pages created, again I followed the same instructions, but, for my News post.php page, I changed the route to:

news/[blogslug:s]

to reflect the new structure.

Here is where the questions and issues start to occur.

My index.php page (templates/pages/news/index.php) as standard would return the first 10 items:

perch_blog_recent_posts(10);

but, as I only want items from the News blog, I restrict this and also, for good measure and clarity, call a seperate template.

perch_blog_custom([
  'count'      => 10,
  'sort'       => 'postDateTime',
  'sort-order' => 'DESC',
  'blog'       => 'news',
  'template' => 'news_in_list.html',
]);

This provides a listing of all the news items, but the title link still displays the format:

mysite/blog/2017-05-01-this-is-a-news-post

rather than:

mysite/news/2017-05-01-this-is-a-news-post

Not sure what I am doing wrong.

Ahh, ok, another penmny dropped. Under settings we only have one blog instance, which has the setting:

/blog/{postSlug}

Do I need to somehow get in here /news/{postSlug} as well.

Sorry, but I am completely confused as to how to get a multiple blog operating, if this is the best way etc.

In 'classic' Perch, I would just get Perch_Blog, copy and rename it all as Perch_News, instal and hey-presto, but I know that this is frowned upon !

I suppose I could do the same thing for Runway, but if Multiple Blogs exist, I would like to work out how to implement them.

Thanks,

Andy

Andrew Kennedy

Andrew Kennedy 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

So you're just having trouble getting the blog slug into the post path?

Try:

/{blogSlug]/{postSlug}

Thanks Drew.

Not sure what was going on. I implemented a hwole bunch of things, tried out a few more, got even more stressed and now have come back to it, put in your suggestion and it all works !!!!

Thank you.

Not sure what was happening before, as it wasn't giving me the intended result, but I tried so many different things and elements that I am unsure as to what was causing the issue.

Anyway, if anyone else runs into trouble, the code you need in the 'Blog post page path' is:

/{blogSlug}/{postSlug}

NOTE: the slight typo in Drew's reply.

Once again, thanks for all your support.