kaz Posted May 21, 2021 Share Posted May 21, 2021 I have done news with Lister, the summary is output via foreach. <?php foreach($pages->find('template=news, sort=date') as $item): ?> I would like to open the full article via <p><a href="<?= $item->url ?>">read more</a></p> into another detail template (news-detail), which I have created. Is there a way to open the $item content in a different detail template, perhaps a second 'template= … ? Link to comment Share on other sites More sharing options...
rash Posted May 22, 2021 Share Posted May 22, 2021 The most simple way to achieve that is to call a detail page (based on a detail template) and specify the news item with a get parameter like so: <p><a href="/newsdetail/?newsid=<?= $item->id; ?>">read more</a></p> In this case, your detail template would contain only the logic to receive an id and render the markup for $item with the given id. If you don’t like get parameters, you could alternatively use form submits instead of <a href> and send the ids as post variables. 2 Link to comment Share on other sites More sharing options...
gebeer Posted May 22, 2021 Share Posted May 22, 2021 A GET parameter is the way to go here, as @rash suggests. You could also use the template name in the get parameter <p><a href="<?= $item->url ?>?template=news-detail">read more</a></p> and then in your news.php template do something like if($input->get->template && $template = $input->get->text('template')) { // check for GET parameter 'template' and sanitize $files->include("{$template}.php") // use $files API to include the template. All API variables (like $page) will be passed } else { // your regular news.php template logic logic goes here } 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now