hi there,
I have a small issue.
Default SMF forum title tag has following pattern
Title: (Main Forum Name)
Title: (Category name)
Title: (Topic Title)
I changed it to
Title: (Main Forum Name)
Title: (Category name) - (Main Forum Name)
Title: (Topic Title) - (Main Forum Name)
using this
<title>', $context['page_title_html_safe']. ' - ', strpos($context['page_title'],$context['forum_name']) === false ? $context['forum_name']. ' ' : '' , '</title>';
This code also checks if current page is forum homepage so it doesnt apply this template to home title to avoid repetition
Now the issue is my forum name is very large and i need it on homepage only, but that complete name is repeating in all titles which is annoying
So what i need is
Title: (Main Forum Name)
Title: (Category name) - (Custom Text)
Title: (Topic Title) - (Custom Text)
is it possible with some modification in above code ?
I am using SMB 2.0.15
try this edit in your index.template.php
echo '
<title>', $context['page_title_html_safe'], '</title>
i'm guessing in your modified file it will be then?
echo '
<title>', $context['page_title_html_safe']. ' - ', strpos($context['page_title'],$context['forum_name']) === false ? $context['forum_name']. ' ' : '' , '</title>';
$custom_text = 'My Custom Text';
if ((empty($_REQUEST['action']) || $_REQUEST['action'] == 'collapse') && empty($_REQUEST['board']) && empty($_REQUEST['topic'])) // on homepage
echo '<title>', $context['forum_name'] ,'</title>';
elseif (empty($_REQUEST['action']) || !empty($_REQUEST['board']) || !empty($_REQUEST['topic'])) // on board or topic
echo'<title>', $context['forum_name'] ,' - ', $custom_text ,'</title>';
else // if not on homepage or board or topic
echo '<title>', $context['page_title_html_safe'] ,'</title>';
echo'
Quote from: Pipke on January 30, 2018, 04:09:06 PM
hi there,
thanks for the help.
here is my current code
<title>', $context['page_title_html_safe']. ' - ', strpos($context['page_title'],$context['forum_name']) === false ? $context['forum_name']. ' ' : '' , '</title>';
There is no
echo ' in the beginning .
when i used your code, it gave me template parsing error.
can you please post your line above and the line below this
<title>', $context['page_title_html_safe']. ' - ', strpos($context['page_title'],$context['forum_name']) === false ? $context['forum_name']. ' ' : '' , '</title>';
Quote from: Pipke on January 31, 2018, 05:32:37 AM
can you please post your line above and the line below this
<title>', $context['page_title_html_safe']. ' - ', strpos($context['page_title'],$context['forum_name']) === false ? $context['forum_name']. ' ' : '' , '</title>';
here is the complete code
echo '
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="', $context['page_title_html_safe'], '" />', !empty($context['meta_keywords']) ? '
<meta name="keywords" content="' . $context['meta_keywords'] . '" />' : '', '
<title>', $context['page_title_html_safe']. ' - ', strpos($context['page_title'],$context['forum_name']) === false ? $context['forum_name']. ' ' : '' , '</title>';
echo '
make it like this
echo '
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="', $context['page_title_html_safe'], '" />', !empty($context['meta_keywords']) ? '
<meta name="keywords" content="' . $context['meta_keywords'] . '" />' : '';
$custom_text = 'My Custom Text';
if ((empty($_REQUEST['action']) || $_REQUEST['action'] == 'collapse') && empty($_REQUEST['board']) && empty($_REQUEST['topic'])) // on homepage
echo '<title>', $context['forum_name'] ,'</title>';
elseif (empty($_REQUEST['action']) || !empty($_REQUEST['board']) || !empty($_REQUEST['topic'])) // on board or topic
echo'<title>', $context['forum_name'] ,' - ', $custom_text ,'</title>';
else // if not on homepage or board or topic
echo '<title>', $context['page_title_html_safe'] ,'</title>';
echo '
Quote from: Pipke on January 31, 2018, 05:58:05 AM
thank you very much.
I make it work by simply replacing
$context['forum_name'] with this $context['page_title_html_safe']
on 8th line
THANK YOU VERY MUCH AGAIN :)