Jump to content

Passing variables in Url


spamec
 Share

Recommended Posts

Hi,

I'm developing my first site with PW. Got it brilliant idea, but head cant get around old thinking :)

My problem: I have to make a list of news categories with links to news-list template with specific category (to filter news out).

Category list:

  <?php $newsIndex = $page->find('template=news-list'); ?>
  <?php $categories = $pages->get('template=news-categories')->children;?>
  <?php foreach($categories as $c): ?>
	<?php echo "<li><a href='{$newsList->url}{$c->path}'>{$c->title}</a></li>"; ?>
  <?php endforeach;?>

Filtering news:

$selectedCategory = '';
$news = $page->children("category={$selectedCategory}, sort=-date");

Question:

  • How to create url to $newsList page with category as parameter?
  • How to get parameter from url and then filter news out?

Maybe, there's any section in API covering this topic (I didnt found it) :)

Link to comment
Share on other sites

Thanks apeisa for support,

creating url is working (was really close), but I'm facing new problem.

My structure:

/news - news-list

/story/news-name - news entry

/news/category-name - which is the case, now when I enter this url I get 404, which is true as page with category-name doesnt exists...

I used to work with MVC pattern, so this is new situation for me (sorry for stupid questions)

Link to comment
Share on other sites

  • 5 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...