News:

Wondering if this will always be free?  See why free is better.

Main Menu

how to use theme_linktree() ?

Started by Deprecated, August 10, 2008, 11:40:31 PM

Previous topic - Next topic

Deprecated

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?

ccbtimewiz

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.

Deprecated

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.

[SiNaN]

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();
Former SMF Core Developer | My Mods | SimplePortal

Deprecated

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?

[SiNaN]

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.
Former SMF Core Developer | My Mods | SimplePortal

Deprecated

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. :)

[SiNaN]

Okay, but better you drink some coffee. :P
Former SMF Core Developer | My Mods | SimplePortal

Deprecated

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();

[SiNaN]

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.
Former SMF Core Developer | My Mods | SimplePortal

Deprecated

Thank you Sinan! Yes, that did it! :)

You are very helpful and thank you very much for your help! :D

ccbtimewiz

Glad to see you were able to solve this. :P

Deprecated

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. :)


Deprecated

This mod is obsolete. SMF included the functionality in the official release a few revisions back.

Advertisement: