TinyPortal

Development => Support => Topic started by: knat on December 19, 2006, 02:09:25 PM

Title: Help needed: How do i add this button with php code to a block ?
Post by: knat on December 19, 2006, 02:09:25 PM
I need help with this

I have the bookmarks mod installed for SMF and i would like to add the button in a block

the code for the button looks like this

if ($context['user']['is_logged'])
echo ($current_action == 'Bookmarks' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'Bookmarks' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=Bookmarks">' , $txt['my_bookmarks'] , '</a>
</td>' , $current_action == 'Bookmarks' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


How do i add that code to a picture of my choise and stick it in a php block ??

The bookmarks action will only work when i use this code.. wich is for the normal smf menu and i dont have that anymore.. so any help would make me happy and thankful  :)
Title: Re: Help needed: How do i add this button with php code to a block ?
Post by: JPDeni on December 19, 2006, 02:29:57 PM
Looks like it would just be


global $scripturl;

echo '<a href="', $scripturl, '?action=Bookmarks"><img src="http://url/to/the/image" /></a>';


You wouldn't want to use the if ($context['user']['is_logged']) conditional because then guests would just see an empty block. Better to only have it viewable for logged-in members.
Title: Re: Help needed: How do i add this button with php code to a block ?
Post by: knat on December 19, 2006, 03:23:57 PM
Thanks alot.. i really sux at the php lol

what if i want to put this code inside some html

i have to use something called php tags ?

Sorry for being a newb  :)
Title: Re: Help needed: How do i add this button with php code to a block ?
Post by: JPDeni on December 19, 2006, 03:57:12 PM
Quotewhat if i want to put this code inside some html
I don't know what you mean. Other html code around it?

If that's what you mean, there are two ways. One is to put the html code within the echo statement. As long as you don't have a ' in there, it won't be a problem. The other way is to hardcode the url to your page instead of using the $scripturl variable.

It would be:


<a href="http://www.yoursite.com/index.php?action=Bookmarks"><img src="http://url/to/the/image" /></a>

Title: Re: Help needed: How do i add this button with php code to a block ?
Post by: knat on December 19, 2006, 05:37:11 PM
goin to www.mysite.com/index.php?action=bookmarks

That dont work.. only way i can get it to work is if i use the above php code.. thats why i was aking about how to convert it to html.. does it contain session id or something ?
Title: Re: Help needed: How do i add this button with php code to a block ?
Post by: knat on December 19, 2006, 05:51:49 PM
OMG i really am the king of newb's  :buck2:

Reason why it wouldn't work was because i didn't use a capital B in bookmarks LoL  :uglystupid2:

Thanks for helping me out  ;)
Title: Re: Help needed: How do i add this button with php code to a block ?
Post by: JPDeni on December 19, 2006, 05:53:09 PM
Good job figuring it out. :) I was just writing that very thing.

You won't forget it next time.  ;D