Jump to content

Stuck with $pages->get("/path/to/page/") inside <a href=""></a>


pwired
 Share

Recommended Posts

I have a problem with this line:
echo '<div id="button3" class="button_style"><a href="./kontakt/">kontakt</a></div>';

Every time when I click on the button, it only 1 time goes to the page kontakt

and after that the word kontakt is added to the link unendlessly,

instead of going to the page kontakt.

So I think I need to use something like:
$pages->get("/path/to/page/")

The page kontakt is a child of home, so I think that would be
$pages->get("/kontakt/")
Now I need to make the word kontakt clickable and link to the internal page kontakt.

echo '<div id="button3" class="button_style"><a href="$pages->get("/kontakt/")">kontakt</a></div>';

I am stuck with the part $pages->get("/kontakt/") how to get this inside <a href=""></a>
in the right way.
 

Link to comment
Share on other sites

Thanks Joss but when I use it like this

echo '<div id="button3" class="button_style"><a href="<?=$pages->get("/kontakt/")->url ?>">kontakt</a></div>';

the kontakt button disappears.

My fault: using two times echo

This is a quote and escape jungle:   "   '   .

I think it has to be something like this:

<a href='<?php echo $pages->get("/kontakt/")->url?>'>kontakt</a>

But the first echo already starts with a single quote

Link to comment
Share on other sites

Please think for 5 seconds before posting! You are opening a php tag inside a php tag. Joss suggested you do that because you weren't clear if you were doing this inside or outside a php tag. You have two choices:

<!-- Outside the PHP tags-->
<div id="button3" class="button_style"><a href="<?=$pages->get("/kontakt/")->url ?>">kontakt</a></div>

or

<?php
// inside the PHP tags. You are using single quotes, so you can't echo variables without closing them
echo '<div id="button3" class="button_style"><a href="' . $pages->get("/kontakt/")->url . '">kontakt</a></div>';
?>
  • Like 3
Link to comment
Share on other sites

Guys you really got me there. I had concatenate in the back of my mind but could not figure it out,

switching back and forth between " and ' or escaping them or use concatenate - couldn´t follow up.

@Joss-martijn-diogo - thanks for your code examples.

Edit: I can add { to the list so now I have   "   '   .

to learn to sort out.

Link to comment
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
 Share

  • Recently Browsing   0 members

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