pwired Posted September 24, 2014 Posted September 24, 2014 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.
Joss Posted September 24, 2014 Posted September 24, 2014 ->url would be missing? <?=$pages->get("/kontakt/")->url ?> Edit ->httpUrl if you want the path including the domain name, though not normally needed.
pwired Posted September 24, 2014 Author Posted September 24, 2014 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
Martijn Geerts Posted September 24, 2014 Posted September 24, 2014 This is a quote and escape jungle Play Tarzan: echo "<div id='button3' class='button_style'><a href='{$pages->get('/kontakt/')->url}'>kontakt</a></div>"; 1
diogo Posted September 24, 2014 Posted September 24, 2014 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>'; ?> 3
pwired Posted September 24, 2014 Author Posted September 24, 2014 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.
Soma Posted September 24, 2014 Posted September 24, 2014 The endless link appending is because of the dot ./kontakt/ ... remove the dot and save a query. 1
Joss Posted September 24, 2014 Posted September 24, 2014 Remove the dot and save a query. You should put that on a T-Shirt. Make it a new campaign. I mean, those Queries need saving before they go extinct! 1
OrganizedFellow Posted September 25, 2014 Posted September 25, 2014 @pwired $SillyGuy = "pwired"; echo $SillyGuy . " please insert code into the code box"; 1
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