Linktree question

Started by DeadMan..., March 31, 2023, 11:11:41 AM

Previous topic - Next topic

DeadMan...

Okay, I have made a simple page for something on my test forum.
Before I try it out on a live site, I noticed that the linktree still says Forum when on my custom page.
How would I set it to state the name of my page when on the page?
Yes, using TinyPortal, which is why it says Forum when viewing the board index.
SMF 2.1.3 - TinyPortal 2.3.0
I tell it how I see it... Don't like it? Hit Alt+F4!

Sesquipedalian

Rewrite the relevant item in $context['linktree'].
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

DeadMan...

How would I do that?
I've done this all as a mod (personal) and do have hooks.
I tell it how I see it... Don't like it? Hit Alt+F4!

mickjav

This is what I use In my main function below the page title

// Linktree
$context['linktree'][] = array(
'url' => $scripturl . '?music;area=charts',
'name' => $txt['Music_artists'],
Site Under redesign not expected to be complete before January 2026

DeadMan...

#4
Thank you, @mickjav!

Is there a way to remove the "Forum" from between the site name and the page name?

Site Name -> Forum -> Page
I tell it how I see it... Don't like it? Hit Alt+F4!

@rjen

I am wondering, HOW did you create this page?

I guess you choose not to make a Tinyportal article?
Because if you had used the article function the link-tree will not be showing the 'forum' bit...

This is what it shows for articles...
1. Site name
2. Category name
3. Article name

You cannot view this attachment.
Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

DeadMan...

I created it by making a mod that uses hooks, and has a source page as well as a template page.
I don't use articles for a few reasons that I don't really want to get into.

I'd rather the page have it's name in URL, menu, linktree, etc., which is one reason I chose to make my own.
Even the Pages mod, nice as it is, has more in the URL, than I care for.
I tell it how I see it... Don't like it? Hit Alt+F4!

@rjen

Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

Arantor

In your custom source, check if $context['linktree'][1] is set and if so remove it before adding any linktree of your own.


(Unless TP hooks it late but that would be mega weird just for that)

DeadMan...

Quote from: Arantor on March 31, 2023, 02:56:38 PMIn your custom source, check if $context['linktree'][1] is set and if so remove it before adding any linktree of your own.

Nothing there, except for what I added:

// Linktree
$context['linktree'][] = array(
'url' => $scripturl . '?action=deadman',
'name' => $txt['deadman_deadman'],);
I tell it how I see it... Don't like it? Hit Alt+F4!

Arantor

Ok, fine, let me figure out how to write this code on an iPad since that was a hint on "the code you need to add so that you can remove the forum item from the link tree that's already there before your code adds *your* item" except typing actual code on an iPad is tedious.

Code ("before the bit you quote above that adds your item, add") Select
// this will be in your source file, you should already have called global $context before you do this bit otherwise it's going to fail regardless
// at this point in time, SMF will already have put the home link into the link tree whatever happens, this happens very very early on, before a given action is called, set up during loadTheme
// I am betting that TP will also have set up its adding the "forum" item to the linktree here already too
// in which case $context['linktree'] already has index 0 (home) and index 1 (forum)
// so we have to check if $context['linktree'][1] is set and if so get rid of it
if(isset($context['linktree'][1]))
    unset($context['linktree'][1];
// now you can add another item to the linktree with your code above
// it would be weird if TP added its item to the linktree *after* you'd added yours

Honestly though if your criteria was as you'd set out, you should have just used SSI and be done with it.

DeadMan...

Nope, still didn't work.

Quote from: Arantor on March 31, 2023, 03:49:00 PMHonestly though if your criteria was as you'd set out, you should have just used SSI and be done with it.

Well, I did it the way I felt would be good.
I am really not good with deep coding, and have not ever did anything like this before, nor used SSI yet, either.
I tell it how I see it... Don't like it? Hit Alt+F4!

Arantor

I tried. I'll take another look when I am sober and in front of an actual laptop though it would help to share the code you have in the meantime to see what you're doing that is weird because I'm not much of a mind reader sober, less of a mind reader while $alcohol->consumed()...

As for SSI... I'm sure I've given examples over the years but basically line 1 is include SSI, 2 is to set $context['page_title'], line 3 is call template_header(), then your content, then the last line is template_footer(), done. Though I think you'd want to also add to $context['linktree'] after the page title.

Advertisement: