Forum

Thread tagged as: Question, Runway, Blog

Using the blog app with runway

Hi

Can you create an article on how to use the blog app in runway. I ask because i am having trouble getting the clean URL that you get in Perch by using the clean url (https://docs.grabaperch.com/addons/blog/installation/clean-urls/) doco. and by changing the Blog post page path.

In perch Runway, It does not seem to matter what URI segment i add blog/[isodat]-{slug} in runway as soon as you change the Blog post path, nothing works.

I have noticed that you also now need to have /blog/post.php in the path field. so you end up with /blog/post.php?s=2014-10-27-my-first-blog as that is what the slug format is in settings.

I am really confused and I think it would help with routing in general to understand this.

Regards,

Brett

Brett Warne

Brett Warne 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

When you say nothing works - what happens?

if i leave everything as it i, the blog app works, but you get /blog/post.php?s=2014-10-27-my-first-blog,

how do i get rid of he post.php?=

and replace it with /blog/2014-10-27-my-first-blog.

in perch you would add

RewriteRule ^blog/([a-zA-Z0-9-/]+)$ /blog/post.php?s=$1 [L]

to achieve this, I have tried blog/[isodat]-{slug} but it seems tied to the Blog post path.

Can you list the steps to /blog/2014-10-27-my-first-blog

Drew McLellan

Drew McLellan 2638 points
Perch Support

You don't need to add any rewrite rules - just add a route in the page details.

Hi Drew

I installed a clean version of runway, install the blog app and moved it into templates/pages. added the new blog, post and archive pages and selected the master page. added a post and it works but has the full /blog/post.php?s=.

It makes no difference what route you add to the page, the blog app is controlled by the settings page and the blog path and slug. If you dont add post.php?s={postTitle} you get the error page

As all the templates are looking for the get(s) , can you have a look and see what can be done to get clean URL in the blog app, i assume the events app will be the same.

If you think i am not doing something correct can you please let me know.

Regards,

Brett Regards,

Brett

Drew McLellan

Drew McLellan 2638 points
Perch Support

perch_get() will retrieve either

  1. Items from the query string ($_GET in PHP parlance)
  2. Numbered segments from the routed page URL
  3. Named segments from the routed page URL

Yeah I seem to be having troubles as well. It only works when you do post.php?s={postTitle} I must be missing something.

Hi Drew

so are you saying that the default post.php page needs to be rewritten

<div class="post">
                <?php perch_blog_post(perch_get('s')); ?>

                <?php perch_blog_author_for_post(perch_get('s')); ?>

                <div class="meta">
                    <div class="cats">
                        <?php perch_blog_post_categories(perch_get('s')); ?>
                    </div>
                    <div class="tags">
                        <?php perch_blog_post_tags(perch_get('s')); ?>
                    </div>
                </div>

                <?php perch_blog_post_comments(perch_get('s')); ?>

                <?php perch_blog_post_comment_form(perch_get('s')); ?>

            </div>

becomes

<div class="post">
                <?php perch_blog_post(perch_get('')); ?>

                <?php perch_blog_author_for_post(perch_get('')); ?>

                <div class="meta">
                    <div class="cats">
                        <?php perch_blog_post_categories(perch_get('')); ?>
                    </div>
                    <div class="tags">
                        <?php perch_blog_post_tags(perch_get('')); ?>
                    </div>
                </div>

                <?php perch_blog_post_comments(perch_get('')); ?>

                <?php perch_blog_post_comment_form(perch_get('')); ?>

            </div>

or do we need to rewite them with

https://docs.grabaperch.com/runway/routing/named-segments/ but change the custom part to blog.

Regards,

Brett

Drew McLellan

Drew McLellan 2638 points
Perch Support

No, I'm not saying that.

Have you set up a page route for your post page? What does it look like?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Should be something like

blog/[slug:s]

I think the confusion is because Blog is an app, and those files live in a blog folder vs pages.

Can you put the blog/post.php file in the pages folder in runway? If so how do you tell runway that the blog app posts are being referenced from the router and not the actual blog directory?

Hi Brandon

You need to put the entire blog folder into pages, you then need to create the three pages in runway, index. post and archive, If you want clean URL,s you need to change the Blog post page path in settings to /blog/{postSlug}

then in the post.php page you need to add blog/[slug:s] to the URL pattern

the archive page will still have /blog/archive.php so its the last thing i need help with from Drew or Rachel

Hi again Drew

how do you get the archive page to not have the .php in the archive page you have the path = /blog/archive.php

in the URL pattern i add / blog/archive

this list all of the tags and categories but not the posts, you need to have /blog/archive.php to list the post

what URL pattern do i need and in my templates do i just add

<a href="/blog/archive">Archive Posts</a>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Where is the link to archive.php being created? I would have thought it's just in the templates.

The blog app has index, post and archive. It is in the template, post-in-list. I want a link to older news.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok. I'm not sure I understand the problem.

I think if you answer my other post I will be able to sort this out.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I can't see any other unanswered posts from you. What's the URL?

Brett Warne said:

You need to put the entire blog folder into pages, you then need to create the three pages in runway, index. post and archive, If you want clean URL,s you need to change the Blog post page path in settings to /blog/{postSlug}

then in the post.php page you need to add blog/[slug:s] to the URL pattern

Thank Brett this worked like a charm.

Hi Drew

The only issue now is how do we change all of the archive.php url,s

so you will have /blog/archive.php?cat= and /blog/archive.php?tag= and /blog/archive.php?year=&month=

do you add multiple url patterns

Drew McLellan

Drew McLellan 2638 points
Perch Support

Sure, something like

blog/archive/category/[slug:cat]
blog/archive/tag/[slug:tag]
blog/archive/[year:year]
blog/archive/[year:year]-[i:month]