Jump to content

wiki.processwire.com - simple news system tutorial

Recommended Posts

Hi guy's

I'm new with PW and very happy with it - thanks alot Ryan and team for this great work!

I just completed the simple news system tutorial on the wiki page (thanks alot to the author - who was it?) - works perfect, except for one thing:

I would like to get the categories-breadcrumb - when a news list of a specific category is displayed - take me to the main news page with all news items listed. Now it gives me 404. Allowing the url segment news/categories - where the breadcrumb points to - in the TUT_news_index template or the TUT_news_index unfortunately didn't make it work.

Same problem with the news-articles breadcrumb link on the article display page. See attached screenshots.

Is anyone familiar with the tutorial / the simple news system and coud give me a hint?

Thanks alot for any help in advance.

Cheers, Markus from beautiful Switzerland



Edited by LostKobrakai
Moved to general support

Share this post

Link to post
Share on other sites

Sorry folks, I have to get into it first - my problem was in fact very simple and here I found simple solution myself:

For each of the two hidden pages "news-articles" and "categories" I made a template-file with the following redirect:

Maybe Joss could add this to the wiki page.
Works perfect now. Problem solved, but is there any built-in way of managing redirects in PW? I could't find any module with this specific functionality.
Cheers, Markus

Share this post

Link to post
Share on other sites

Hi Mr Fan

sorry again. In the access-tab of a no-file template I only get the first row ("do you want to manage..."). The rest ("What to do..." is missing. Where can I get it? Do I have to install a module first?


Share this post

Link to post
Share on other sites

Oh sorry forgot - empty template file is missing....but you don't habe to redirect manual via session....just fast from the phone...

edit: should really work without template file...

Edited by mr-fan

Share this post

Link to post
Share on other sites

Danke, mr-fan

I made a totally empty template file now and attached it to the template. The access-tab still looks the same. Also with other templets with associated template files the access-tab looks all the same. Any other thing to do?

Share this post

Link to post
Share on other sites

PW Version?

Have you checked the [x] yes at the first setting?

and i've checked again it should be possible without template file...

Regards mr-fan

Share this post

Link to post
Share on other sites


sorry for my slow comprehension. I had to uncheck the access for guests first, then the rest popped up. Actually works now, but since this redirection method has effect on the parent page also when children are accessed, it is usesless for me. I want a redirect only when only the parent (without children) is accessed. A bit tricky - so probably I will have to stay with the $session->redirect() which works perfect for my needs.

Thank you anyway for your time and help!

Regards, Markus

Share this post

Link to post
Share on other sites

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By louisstephens
      So I have been hard at work creating url segments for a template (api) and everything is working swimmingly in creating a simple end point for svelte.js. I have however, run into a few questions that I can wrap my head around.
      In my api template I have:
      if($input->urlSegment1 === 'clients') { header('Content-Type: application/json'); $clients = $pages->find("template=clients"); $client_array = array(); foreach ($clients as $client) { $id = $client->id; $title = $client->title; $url = $client->url; $clientName = $client->client_name; $clientColor = $client->client_color->value; $assigned = $client->assigned_to->user_full_name; $client_array[] = array( 'id' => $id, 'code' => $title, 'name' => $clientName, 'associated_users' => $assigned, 'url' => $url ); } $client_json = json_encode($client_array, true); echo $client_json; } The output json from this is:
      [ { "id":1644, "code":"abc", "name":"Test Name", "associated_users":null, "url":"\/pw\/clients\/abc\/" }, { "id": 1645, "code": "xyz", "name": "Test Name", "associated_users": null, "url": "\/pw\/clients\/xyz\/" }, ] I was curious is it possible to add in "clients" before this output json so it would appear as 
      clients: [ { "id":1644, "code":"abc", "name":"Test Name", "associated_users":null, "url":"\/pw\/clients\/abc\/" }, { "id": 1645, "code": "xyz", "name": "Test Name", "associated_users": null, "url": "\/pw\/clients\/xyz\/" }, ] I was not really sure of how to tackle this in my php code, and have spent more time than I care to admit trying to figure it out. Another question I have is that "associated_users" is returning null, which in this instance is correct. It is a multi page field that is set to pull a custom name field from the users template, ie "Louis Stephens" would be associated with the first page. I understand that I need to use a foreach to get the correct data, but I was really unsure of how to place this inside an array, or update the array with the new data. Any help with any of this would greatly be appreciated.
    • By stanoliver
      The following code snippet is part of my markup simple navigation and the url_redirect (url field in the backend) just works fine when I put an special custom url into the url_redirect field.
      <?php $nav = $modules->get("MarkupSimpleNavigation"); // topnav $current = $page->rootParent(); // current root page // subnav echo $nav->render(array( 'max_levels' => 2, 'item_tpl' => '<h4><a class="g8-bar-item g8-hover-black" href="{url_redirect|url}">{title}</a></h4><hr class="sidenav">', 'collapsed' => true, ), $page, $current); ?>  In my seperated breadcrumb navigation I use the following code snippet
      <?php foreach($page->parents()->append($page) as $parent) { echo "<li><a href='{$parent->url_redirect|url}'>{$parent->title}</a></li>"; } ?> Now to the problem: In my first code snippet above the
      works just fine but when I try something similiar in the second code snippet
      I produce an server error How do I have to change the second code snippet so that it works in the correct way as the first code snippet does?
    • By Moritz Both
      For our PW project we use markup regions and, for one template, url segments. The documentation recommends throwing a new Wire404Exception() from the template when the code concludes that the url segments from the request are invalid, and so we do.
      However, the 404 page is not displayed properly. Viewing the page source in the browser we can see that the original, unmodified markup region contents from our _init.php file is prepended to the correct html output, messing the whole page up.
      Any advice is greatly appreciated.
    • By hansv
      Hi everybody
      I want to catch a variable from outside processwire into _main.php
      if(isset($_GET['u']) && $_GET['u'] !== ''){ $gebruikersnaam = $_GET['u']; ... ... This is working fine in a php file in a non processwire environment. 
      In a processwire environment, I get the variable when I refer to /site/templates/_main.php but a great part of my template-code is not shown. 
      From outside processwire I refer to    mydomain/index.php.  If I place   $gebruikersnaam = $_GET['u'];  in index.php, how can I pass through my variable to _main.php?   Or is there an other solution?
    • By quickjeff
      Hi Guys,
      Right now, I am using parents as breadcrumbs but I have pages under a parent page just to keep things organized. The pages are called in other areas of the site. 
      I am trying to create user path history breadcrumbs.
      Meaning: If the user clicked a link to the page, it will show the path he took. Has anyone done this? Would love to see who has before I dive in.
  • Create New...