How to pass data to a page from another when a link is clicked?

Permalink 1 user found helpful
Hey there!
I am in the middle of developing a custom block, that lists some articles from a database. When a user clicks on one of the links representing an article, a more detailed information page should be displayed about the article. I figured, that I would use a single page for displaying the articles, and pass some data with information regarding which article to display in detail, but I could not figure out a way to pass data to the page by a single click on a simple link (that is, without the use of forms!) Any tips on how to achieve this? Thanks!

 
JohntheFish replied on at Permalink Reply
JohntheFish
If you make each article a page, then you can use a page list block (or one of its many variants) to provide the index page.

If regular blocks won't do the article, then create a suitable block with designer content or from scratch.
goutnet replied on at Permalink Reply
you could simply add an id in the get request :

<a href="myurl?myID=something">Link</a>


and configure your destination page to pick it up there.

You can also use javascript to add post data to the http request.
szucslaszlo replied on at Permalink Reply
Hey guys! Thank for your tips. Unfortunatelly, none of them can be used in the solution. The 'article' can be anythins actually, and there can be hundreds or thousands of them - so creating each article as a page, is not an option. I would store them in a separate table in the database. Also, building up the detailed content of each article manually is not an option - the content has to be generated from the database. Managing of article data would happen through a dashboard single page. I am somehow feeling against using query strings. I don't know why, but I feel it is possibly not quite user (and SEO) friendly - but I may be wrong. Is there possibly some other solution? Or is it totally okay to use query strings for this task?
JohntheFish replied on at Permalink Best Answer Reply
JohntheFish
I still think you are looking at this the wrong way round. A page in a cms **is just** a few entries in a database!

You can have a dashboard single page that, when an article is entered, creates the cms page for the article. This would probably be a page type with an 'article' block inserted into the main area.

Discussion forums on this site work that way, and there are hundreds of thousands of 'pages' (ie, posts). Blogs work that way in concrete5. Many of the calendar/events addons work that way (though the case for doing events that way is not as definitive).

If your requirements can be sufficiently generalised, you can use the c5 composer as the dashboard page for entering articles.

On a separate topic: For the url parameter string, you could get round that by making each link a small form and with post parameters. Or use jQuery to do such conversion dynamically.
szucslaszlo replied on at Permalink Reply
Hello John! Allright, I get your point - I just had a feeling that this is not the way pages should be used. Like if it was bad practice (something being represented with a page, that is semantically something totally different) - but if this is not the case, than I guess I should not make this overly complicated. Thanks!
chemmett replied on at Permalink Reply
chemmett
C5 will handle thousands of pages without any problem, and I think John's solution is the best one.

But if you still wanted to use a single page with a separate DB, query strings are about the only option that *is* SEO friendly. If you use a hidden form, javascript or cookies to pass the data, search engines won't be able to crawl any of those links.

If you're concerned about the "look" of GET variables, use an Apache rewrite rule to rewrite them. So (for example) the user sees the link domain.com/articles/12-article-title but it's being rewritten to something like domain.com/single_page?article_id=12