Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: Deprecated on August 10, 2008, 11:40:31 PM

Title: how to use theme_linktree() ?
Post by: Deprecated on August 10, 2008, 11:40:31 PM
I'm trying to emulate the appearance of other SMF pages for my custom page. I'm talking about the stuff above this post:

Simple Machines Community Forum > Customizing SMF > SMF Coding Discussion > Start new topic

I call theme_linktree() and it returns the tree wrapped in <SPAN> tags.

My new page is one below the top page so it should look like this:

Forum Name > My New Page

But it doesn't know about my page so it shows up as:

Forum Name

I've looked at other pages that use it and they don't seem to be doing anything special to manipulate it. Typically something like this:

        <div style="padding: 3px;">', theme_linktree(), '</div>


How do I tell it I want My New Page and its URL to show up in the link tree?
Title: Re: how to use theme_linktree() ?
Post by: ccbtimewiz on August 10, 2008, 11:53:15 PM
You'd build the link in the .php source syntax...

Like..

$context['linktree'][] = array(
'url' => $scripturl.'?action=youraction
'name' => 'the name of your action',
'extra_before' => 'stuff to go before it, like ( or )'
);


Hope that helps you out with this.
Title: Re: how to use theme_linktree() ?
Post by: Deprecated on August 11, 2008, 10:09:43 AM
I'm sorry, I don't understand. The link tree is already built. It has the correct data for the parent process. I just want the child process My New Page to add its link to the existing link tree. And will that be passed on to child of New Page? I cannot find any code doing this in SMF despite being able to see it in operation as you go from index to category to board to topic. I'm missing something important in my understanding.
Title: Re: how to use theme_linktree() ?
Post by: [SiNaN] on August 11, 2008, 10:15:02 AM
Okay, let's make it more simple.

You use theme_linktree(); but SMF doesn't recognize your page, right?

So teach him what your page is. ;)

Add your page into the $context['linktree'] array before calling the function. Url index is for href, and name is for name.

$context['linktree'][] = array(
      'url' => $scripturl.'?action=youraction',
      'name' => 'the name of your action'
   );

theme_linktree();
Title: Re: how to use theme_linktree() ?
Post by: Deprecated on August 11, 2008, 10:18:02 AM
Please bear with me, this is my third morning after quitting coffee and I'm not quite sure if I'm fully in the real world...

The linktree already has the name of the forum and a link to it.

Does your code above replace the existing linktree or add to it?
Title: Re: how to use theme_linktree() ?
Post by: [SiNaN] on August 11, 2008, 10:25:58 AM
Okay, let's make it the simplest.

When I use this:

theme_linktree();

It show this:

Forum

When I use this:

$context['linktree'][] = array(
      'url' => $scripturl.'?action=youraction',
      'name' => 'the name of your action'
   );

theme_linktree();


It shows

Forum >> the name of your action

It adds on your linktree.
Title: Re: how to use theme_linktree() ?
Post by: Deprecated on August 11, 2008, 11:08:28 AM
Thanks Sinan. That looks like it will work to me. I'll go pop that in my code and see if I've got it right. :)
Title: Re: how to use theme_linktree() ?
Post by: [SiNaN] on August 11, 2008, 11:09:55 AM
Okay, but better you drink some coffee. :P
Title: Re: how to use theme_linktree() ?
Post by: Deprecated on August 11, 2008, 11:15:33 AM
All I'm getting is the name of the forum, not my page:


This is Mypage.template.php

function template_main() {

   global $scripturl, $txt, $modSettings;

$context['linktree'][] = array(
      'url' => $scripturl.'?action=mypage',
      'name' => 'My Page'
   );

echo theme_linktree();
Title: Re: how to use theme_linktree() ?
Post by: [SiNaN] on August 11, 2008, 11:17:15 AM
You really need some coffee. :P

$context should be in globals.

Also if you have a source file, then you should add this code in somewhere in the source file:

$context['linktree'][] = array(
      'url' => $scripturl.'?action=mpyage',
      'name' => 'Mypage'
   );


Then just use:

echo theme_linktree();

in template file.
Title: Re: how to use theme_linktree() ?
Post by: Deprecated on August 11, 2008, 11:36:33 AM
Thank you Sinan! Yes, that did it! :)

You are very helpful and thank you very much for your help! :D
Title: Re: how to use theme_linktree() ?
Post by: ccbtimewiz on August 11, 2008, 11:37:21 AM
Glad to see you were able to solve this. :P
Title: Re: how to use theme_linktree() ?
Post by: Deprecated on August 11, 2008, 12:05:13 PM
Thanks CCB. :) It's my secret (shhhhh!!!!) bigger mod I'm working on. Instead of only having a ridiculous 2-3 lines this time my mod may have as many as 12 or even 15 lines...

Hahaha, got you! I'm joking. It's a lot bigger than that! ;)

Don't be surprised when my "how to add config to admin control panel" questions start. But I'll reverse engineer some other mods and see if I can figure it out on my own. A year from now I'll be laughing at novices the level I am now, remembering when I was such a n00b. :)
Title: Re: how to use theme_linktree() ?
Post by: Biology Forums on August 28, 2014, 04:51:59 PM
Thanks for this tutorial.
Title: Re: how to use theme_linktree() ?
Post by: Deprecated on February 08, 2015, 08:30:18 PM
This mod is obsolete. SMF included the functionality in the official release a few revisions back.