Jump to content
stanoliver

redirect url field for breadcrumbs

Recommended Posts

Hi! 

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

url_redirect|url 

works just fine but when I try something similiar in the second code snippet

$parent->url_redirect|url

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?

Share this post


Link to post
Share on other sites

The first one is template syntax, the second one plain PHP.

echo "<li><a href='{$parent->get('url_redirect|url')}'>{$parent->title}</a></li>";
// or:
echo "<li><a href='" . $parent->get('url_redirect|url') . ">{$parent->title}</a></li>";

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
35 minutes ago, stanoliver said:

if php was not such an awful language

no it isn't. What makes you say that?

Perhaps you should spend some time "learning the ropes" instead, before declaring an entire decades-long tried and tested scripting language as "awful".

  • Like 2

Share this post


Link to post
Share on other sites

@draganWell, I did not say that php is worthless because is one of the most used programming languages out there and it runs in a simple shared host enviroment.

Have a look at the elegance of languages like elixir, julia, ruby or even pyton then you will know why I consider php a mess. Php is the same mess as javascript  even when both languages are used heavily.

If python, julia or elixir would run in simple shared host enviroments for a 3-4 Euros a month then there would be no need for php anymore.

Share this post


Link to post
Share on other sites

A Ferrari 360 is way more elegant than a VW Golf V but still... you can't move more than 4 boxes (4x 12 bottles) of beer with it.

So... if you feel fancy, you can pay for it - as in hosting prices. Actually Python is supported pretty good in most of the hosting environments I know. And compared to cars it's kind of a Porsche Cayenne and you can move 10 boxes of beer with it and still can go 230km/h if you wanted to.

  • Haha 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By gregory
      Hi everyone.
      I can't see the PDF uploaded via a field called "pdf".
      I get a url like this: http://localhost:8888/mywebsite/site/assets/files/1129/test.pdf%EF%BB%BF%EF%BB%BF
      Could anyone help me? Thank you.
      <?php foreach($page->case_studies as $item) { if($item->type == 'contenuto') { echo " <a class='btn btn-primary btn-sm' target='blank' href='{$item->pdf->first()->url}' role='button'>Download</a> "; } } ?>  
    • By ce90
      Hello everyone,
      hopefully this is the right place to ask and is not a duplicate question.
      I'm pretty new to processwire, so... if this question is kind of funny for some of you, you're welcome 😄 
      I have the following issue and can't find anything understandable about it. Maybe I'm searching the wrong way, but anyways.. here is my question:

      How is it possible to rewrite the URLs, that I'll get a *.php ending?
      Example:
      https://www.mysite.de/urlsegment/ -> https://www.mysite.de/urlsegment.php
      https://www.mysite.de/urlsegment/urlsegment/ -> https://www.mysite.de/urlsegment/urlsegment.php
      Because I've read a lot about "Why do you wanna do this or have that?" – here my answer for that in advance:
      I've built a processwire installation inside or around an existing website. Therefore, we want to keep the existing *.php Google entries. Sure, we could redirect via 301 Redirect, but would prefer to keep the *.php ending.
      If you have further questions, please do not hesitate to ask.
      Thank you in advance for your help.

      Best regards
      ce90
    • By Orkun
      Hi Guys
      How can I make a redirect inside the .htaccess to my custom maintenance.html file when any URL of my Website is accessed except the processwire admin (www.example.com/processwire/).
      Because I want that my User's still can access the website when they are loggedin in Processwire.
      When the current url starts with /processwire or if there is a processwire-login-cookie (Is there a cookie when user is logged in Processwire?) available the redirect should not work. Otherwise it should work.
      How can I achieve this?
    • By ridgedale
      Reference: PW 3.0.111 and uikit3 based site using the Regular-Master profile.
      I'm trying to automatically redirect a logged-in user to a custom profile page using $session->redirect() and need to add $user->name to the redirect path.
      All my attempts appear to have failed:
      $session->redirect('/user-profile/')->name; $session->redirect('/user-profile/')->$user->name; $session->redirect('/user-profile/' . get($user->name . '/')); $session->redirect('/user-profile/' & get($user->name)); Can anyone point out where I am going wrong?
    • By zota
      Hi,
      After 2 or 3 cliks on my nav bar the browser starts to show
      http://julio.x10host.com/home/juliox15/public_html/logos/
      instead of
      http://julio.x10host.com/logos/
      Where or what should I start the fixing?
      Thanks
×
×
  • Create New...