SimplePortal

Support => English Support => Topic started by: perfec2 on February 01, 2013, 06:06:26 AM

Title: I want my Descriptive Title Appear in Home only
Post by: perfec2 on February 01, 2013, 06:06:26 AM
I want my descriptive title to appear in the Home index only not appearing in email members receive or boards.
For example when I go to Server Settings > core configuration and put my "Forum name" that becomes the forum name, which is fine.
But when I put "Forum name plus important keywords" That also appear in emails members get and forum boards as the forum name which don't want.

What can I edit to put descriptive words keywords I want to only display in HOME only not anywhere else or emails members get.
Note I'm using simply portal that is why I write here, as I have edited the language and got what I want but that only worked in myforumname.com/forum  but couldn't figure out how to make it work in Portal index page only which is the Home.


I will appreciate assistance in this regard.

 
Title: Re: I want my Descriptive Title Appear in Home only
Post by: ccbtimewiz on February 01, 2013, 05:46:10 PM
So, based on the adaptions you've made already, you simply want to change the title of the page for the portal? This can be done fairly easy by editing the source file.

For SMF 1.1 and SMF 2.0:

Open /Sources/PortalMain.php

Within the sportal_main() function, find:

Code: [Select]
$context['page_title'] = $context['forum_name'];
Replace with:

Code: [Select]
$context['page_title'] = 'This is the title you want to use';
Change the text within the apostrophes after the equals sign. Do not add additional apostrophes without escaping them, such as:

$context['page_title'] = 'You\'re escaping the apostrophe!';

Make sure you backup the file before editing it, to avoid any problems.
Title: Re: I want my Descriptive Title Appear in Home only
Post by: perfec2 on February 01, 2013, 09:02:23 PM
That solved it, thank you for your assistance.
Title: Re: I want my Descriptive Title Appear in Home only
Post by: perfec2 on February 04, 2013, 04:22:35 AM
Is there any way I can also make the portal to have it's own metal Description and Keywords not using general forum own just like it has independent title.
Please what is the code to do this and how can I do it?
Title: Re: I want my Descriptive Title Appear in Home only
Post by: andy on February 04, 2013, 05:51:18 AM
I do not think it is possible to have different meta data with the portal page or with custom Simple Portal pages. I might be wrong...
It would be a nice idea for a feature of SP custom pages - have an admin setting for meta description and keywords.

This topic is discussed a lot on the SMF site and many developers there think it is not so important these days as the big search companies use the content on pages to index it.
Still, there are mods for SMF (search on their site) to help improve meta data, but nothing for Simple Portal I know of.

It could be done with custom code I guess.
Title: Re: I want my Descriptive Title Appear in Home only
Post by: perfec2 on February 04, 2013, 08:56:55 AM
Thank you for your elaboration on this. I know if I put normal metal tags code it will appear, but I'm concern that I might mess things up because portal pull up "Description and keywords" of metal tags of the main forum, that is why I want to know from the owner of Simple portal.
Title: Re: I want my Descriptive Title Appear in Home only
Post by: Chen Zhen on February 04, 2013, 12:50:19 PM
perfec2,

  What you are requesting requires some manually editing of a file as attempting to edit the html client side via javascript or jQuery would be fruitless as search engine bots ignore javascript.

  Perform the edits shown below and your home page will have its own meta description & meta keywords as compared to the rest of your forum.

File: Sources/Subs.php

find:
Code: [Select]
// Set some specific vars.
$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title']));
$context['meta_keywords'] = !empty($modSettings['meta_keywords']) ? $smcFunc['htmlspecialchars']($modSettings['meta_keywords']) : '';
}

Replace the above code with:
Code: [Select]
// Set some specific vars.
$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title']));
$context['meta_keywords'] = !empty($modSettings['meta_keywords']) ? $smcFunc['htmlspecialchars']($modSettings['meta_keywords']) : '';

global $boardurl;
if (((!empty($modSettings['sp_standalone_url'])) && $modSettings['sp_standalone_url'] == currentPageURL()) || ($modSettings['sp_portal_mode'] != 0 && rtrim($boardurl, '/') == currentPageURL()))
{
$home_description = 'New Description';
$home_key_words = 'podcasts, mp3, music, movies';
$context['page_title_html_safe'] = $smcFunc['htmlspecialchars']($home_description);
$context['meta_keywords'] = $smcFunc['htmlspecialchars']($home_key_words);
}

}

/* Current url */
function currentPageURL($pageURL = 'http://')
{        
if (!empty($_SERVER["HTTPS"]))
$pageURL = "https://";

if ($_SERVER["SERVER_PORT"] != "80")
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
else
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 
$pageURL = str_replace('index.php', '', $pageURL);
return rtrim($pageURL, '/');


Adjust the following from the above to your specifics:
Code: [Select]
$home_description = 'New Description';
$home_key_words = 'podcasts, mp3, music, movies';
Title: Re: I want my Descriptive Title Appear in Home only
Post by: perfec2 on February 04, 2013, 02:12:05 PM
Does $home_title = 'New Title'; means "description" as I don't want to temper with the portal title as that has been taken care of by Bullet assistance above. All I want now are only "description and keyword" in the Portal only see example below, something that will give me result like:

<meta name="description" content="I describe what my lovely and informative forum is  " />
<meta name="keywords" content="Keyword 1,Keyword2, Keyword 3, Keyword 4, Keyword5 />
Title: Re: I want my Descriptive Title Appear in Home only
Post by: Chen Zhen on February 04, 2013, 05:00:30 PM
perfec2,

  Yes it will only change the meta description & key words on your home page as requested. I have now changed the language from the above post as not to confuse you.
Title: Re: I want my Descriptive Title Appear in Home only
Post by: perfec2 on February 05, 2013, 11:34:16 AM
Thank you for clarification, I'm using 1.x version of smf, for pass 30 minutes now I couldn't find that very code, please in line what is that?
Title: Re: I want my Descriptive Title Appear in Home only
Post by: Chen Zhen on February 05, 2013, 02:55:14 PM
The edits I previously gave you were for SMF 2.0x

Here are the edits for SMF 1.1.16


File: Sources/Subs.php

find:
Code: [Select]
if (!isset($context['page_title']))
$context['page_title'] = '';
}

Replace with:
Code: [Select]
if (!isset($context['page_title']))
$context['page_title'] = '';

global $boardurl;
if (((!empty($modSettings['sp_standalone_url'])) && $modSettings['sp_standalone_url'] == currentPage()) || ($modSettings['sp_portal_mode'] != 0 && rtrim($boardurl, '/') == currentPage()))
{
$home_description = 'New description for home page';
$home_key_words = 'podcasts, mp3, music, movies';
}
else
{
$home_description = $context['page_title'];
$home_key_words = 'PHP, MySQL, bulletin, board, free, open, source, smf, simple, machines, forum';

}

$context['page_title'] = htmlspecialchars($home_description, ENT_QUOTES);
$context['meta_keywords'] = htmlspecialchars($home_key_words, ENT_QUOTES);

}

/* Current url */
function currentPage($pageURL = 'http://')
{        
if (!empty($_SERVER["HTTPS"]))
$pageURL = "https://";

if ($_SERVER["SERVER_PORT"] != "80")
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
else
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 
$pageURL = str_replace('index.php', '', $pageURL);
return rtrim($pageURL, '/');


File: Themes/default/index.template.php
(This edit will have to be performed for all themes that are available to your users)
Find:
Code: [Select]
<meta name="description" content="', $context['page_title'], '" />', empty($context['robot_no_index']) ? '' : '
<meta name="robots" content="noindex" />', '
<meta name="keywords" content="PHP, MySQL, bulletin, board, free, open, source, smf, simple, machines, forum" />

Replace with:
Code: [Select]
<meta name="description" content="', htmlspecialchars_decode($context['page_title']), '" />', empty($context['robot_no_index']) ? '' : '
<meta name="robots" content="noindex" />', '
<meta name="keywords" content="', htmlspecialchars_decode($context['meta_keywords']), '" />
Title: Re: I want my Descriptive Title Appear in Home only
Post by: perfec2 on February 05, 2013, 07:04:54 PM
I can see this will address my need, however, I couldn't find the code to replace in my Sources/Subs.php 1.17 version of smf
Title: Re: I want my Descriptive Title Appear in Home only
Post by: Chen Zhen on February 05, 2013, 08:25:54 PM

perfec2,

 I found it without issue. Use ctrl-f (or cmd-f for apple) to find the text you are looking for.

Title: Re: I want my Descriptive Title Appear in Home only
Post by: perfec2 on February 06, 2013, 05:20:41 AM
The least of the forum works fine as expected, but that of Portal went and duplicated   $home_description = 'all my descriptions'      in the title by overwriting the portal title.
Title: Re: I want my Descriptive Title Appear in Home only
Post by: Chen Zhen on February 06, 2013, 05:37:15 AM
The least of the forum works fine as expected, but that of Portal went and duplicated   $home_description = 'all my descriptions'      in the title by overwriting the portal title.

perfec2,

  I do not understand the above statement. I provided you with edits that will change the meta tags for forum description & key words only on the home page & apply the default settings on all other pages. I do believe that is what was requested.  I can only assume you know how to apply those edits properly and omit any previous edits people gave you that may cause unwanted ouput.
Title: Re: I want my Descriptive Title Appear in Home only
Post by: perfec2 on February 06, 2013, 06:03:36 AM
No previous edit code other than this thread. What I mean is metal tag descriptions on the portal appears in the portal title too by replacing the main portal title. But that of less of the forum is working as expected.
Title: Re: I want my Descriptive Title Appear in Home only
Post by: Chen Zhen on February 06, 2013, 03:48:41 PM
perfec2,

  The term in html language is meta tag, not metal tag.

  I believe I previously misunderstood. The meta description is the title of the page used by search engines & what you are trying to edit is the forum title just for the home page.

Change part of the code I previously gave you as such:
Code: [Select]
global $boardurl;
if (((!empty($modSettings['sp_standalone_url'])) && $modSettings['sp_standalone_url'] == currentPageURL()) || ($modSettings['sp_portal_mode'] != 0 && rtrim($boardurl, '/') == currentPageURL()))
{
$home_description = 'New description for home page';
$home_key_words = 'podcasts, mp3, music, movies, "testing!!"';
$home_title = 'Forum title for home page';
}
else
{
$home_description = $context['page_title'];
$home_key_words = 'PHP, MySQL, bulletin, board, free, open, source, smf, simple, machines, forum';
$home_title = $context['forum_name'];

}

$context['page_title'] = htmlspecialchars($home_description, ENT_QUOTES);
$context['meta_keywords'] = htmlspecialchars($home_key_words, ENT_QUOTES);
$context['forum_name'] = htmlspecialchars($home_title, ENT_QUOTES);

and in every theme's index.template.php

find all occurrences of (ie. default has 3 occurrences):
Code: [Select]
$context['forum_name']

replace with:
Code: [Select]
htmlspecialchars_decode($context['forum_name'])

Title: Re: I want my Descriptive Title Appear in Home only
Post by: perfec2 on February 06, 2013, 05:58:27 PM
I know is Meta tag, but for unknown reason be typing metal tag. Thank for calling my attention to it.

What I want is independent meta description and keywords of Portal (which the home www.thewebsite.com) to be different from the less of the forum which is www.thewebsite.com/forum.
I'm familiar with smf theme and know that Themes/default/index.template.php is the main index of all.
I'm here because of simple portal, Title issue has been addressed by Bullet above instruction, but want "Description and keywords address too if is possible.

Thank you for the good assistance so far.
Title: Re: I want my Descriptive Title Appear in Home only
Post by: Chen Zhen on February 06, 2013, 10:54:38 PM
I know is Meta tag, but for unknown reason be typing metal tag. Thank for caring my attention to it.

What I want is independent meta description and keywords of Portal (which the home www.thewebsite.com) to be different from the less of the forum which is www.thewebsite.com/forum.
I'm familiar with smf theme and know that Themes/default/index.template.php is the main index of all.
I'm here because of simple portal, Title issue has been addressed by Bullet above instruction, but want "Description and keywords address too if is possible.

Thank you for the good assistance so far.

perfec2,

  From what I understand I have produced the exact outcome that you have repeatedly requested.

  What I posted should allow you to have alternate/specific meta keywords, meta description & forum title on your portal home page and different one's on all the rest of your forum. If this is not what you require then perhaps someone else can understand what you are after and will respond to this thread.

Quote
Description and keywords address too if is possible.

I have addressed them & when I test the edits I gave you it works for me without issue.  The only thing that could possibly cause an issue here is the mod you are using to shorten the url but the logic I wrote should only change the meta (& title if opted) when the url is one that shows the portal home page.
Title: Re: I want my Descriptive Title Appear in Home only
Post by: perfec2 on February 26, 2013, 03:48:29 PM
Thank you for the assistance, specially the one you gave me in other thread.
However, I have set up new forum in my localhost, and and still have "description contents"  appearing in the title.

All I want is description and keywords only for Portal  not effecting anything title or boards users use.

SimplePortal 2.3.8 © 2008-2024, SimplePortal