Customizing SMF > SMF Coding Discussion

How to display category in title site??

<< < (4/4)

Arantor:
If you really, really must have the category name in the title, you can test that count($context['linktree']) > 3, and if it is, $context['linktree'][1]['name'] should be the category element of the linktree.

The reason for testing linktree as having at least 4 elements is that the only place I can remember the linktree having that many elements is in topics/posting topics, where the link tree is forum > category > board > topic/post.

MESWEB:

--- Quote from: Arantor on June 02, 2012, 04:49:02 PM ---If you really, really must have the category name in the title, you can test that count($context['linktree']) > 3, and if it is, $context['linktree'][1]['name'] should be the category element of the linktree.

The reason for testing linktree as having at least 4 elements is that the only place I can remember the linktree having that many elements is in topics/posting topics, where the link tree is forum > category > board > topic/post.

--- End quote ---


--- Code: ---<meta name="description" content="', $context['page_title_html_safe'], $context['linktree'][1]['name'],'" />', !empty($context['meta_keywords']) ? '
--- End code ---
Error:

--- Code: ---http://yoump3.pl/index.php?action=forum
8: Undefined offset: 1
Plik: /home/messiah/public_html/Themes/extreme6_2_0_texture/index.template.php
Line: 136
--- End code ---

Arantor:
Well, if you'd implemented what I'd *said*, it would work. I didn't say to use $context['linktree'][1]['name'] on its own, I *specifically said* to check the number of items in it FIRST.


As in:

--- Code: ---<meta name="description" content="', $context['page_title_html_safe'], count($context['linktree']) > 3 ? $context['linktree'][1]['name'] : '','" />', !empty($context['meta_keywords']) ? '
--- End code ---

* Arantor notes that people apparently not reading his posts thoroughly is one of the single biggest sources of frustration in trying to offer support.

Navigation

[0] Message Index

[*] Previous page

Go to full version