Single article view and page numeration problem
This is an open discussion with 3 replies, filed under General.
Search
The extension Versatile Router is what you need. Routes are defined in PHP and can include conditions such as when_number.':page_num'
.
Using two pages, news-list
and news-article
, routing can be done like this:
get('/news/:page_num/', '/news-list/{:page_num}/', array(when_number.':page_num')); get('/news/:article/', '/news-article/{:article}/');
Note that parameter names cannot include a hyphen -- there is a technical reason.
Reygoch, if I understand correctly you would simply need two pages for this.
Create a separate one to display the article, for example called "view", in which case the url would become page.com/news/view/article-title
. Remember to add a title parameter to this page; keep the page-number only for the "list articles" page.
You'll need to create a separate data source to attach to the new page that will only output one article based on the title parameter.
@ellie yes, but I would like to get rid of "view" part of my url. It would be cool if we would have conditional filters.
Than I could say in my datasource something like isNotNum($attr) and if expression is true than I'd use a filter to filter articles by their alias.
Otherwise I'd use attribute as page number or something.
Create an account or sign in to comment.
I'm having some trouble with page numeration and single article view.
This is an example URL that I want to have on my page:
So, if I go to
page.com/news/2
I would get to the second page of news which lists ~10 article intros.And if I go to
page.com/news/article-title
I would get page that shows single and full article.I was checking tutorial on this, but it seems a bit out of date. From what I've figured out, I have to set parameters directly in the page settings, but I'm not sure what should be entered in there, since I use same "position" for two different types of arguments.
Any advice on this? :D