News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Add Link to Main Website Page for SMF v2.x (can't apply v1.x Mod)

Started by Augster, July 19, 2010, 10:41:20 AM

Previous topic - Next topic

Augster

This v1.x thread http://www.simplemachines.org/community/index.php?topic=303343.0 to add a link back to a website's main home page is no longer applicable with v2.x, so I'm starting a new v2.x thread.

Ideally, what I want is to repurpose the existing "Home" button to bring a visitor back to my main website page, while adding a new button (titled, say "Forum") to take over existing functionality of the "Home"

I was able to change the forum logo to my company logo but I would also like it to be a hyperlink to the main website page as well.  I didn't try to apply traditional handcoding HTML to the code that displays the logo just yet since I don't want to inadvertently break it since things are definitely different than v1.x.

EDIT: Okay, I figured out how to change the word "Home" to something else using the Admin->Configuration->Languages...->Edit Languages, click on the specific language (e.g. English) then select the template => General Strings

WHEW!

Now I need someone to help me add link to logo plus add new button!

CapadY

Go to /sources/subs.php and have a look nearly at the bottom of the file.
Here the menubar is defined and you will be able to add a button "Home" to your homepage.
Please, don't PM me for support unless invited.
If you don't understand this, you will be blacklisted.

Augster

Okay, I am assuming if I enter my own code here to add custom buttons, this will not properly work if different languages are selected by the visitor (which I have allowed them to change), no?

CapadY

Depend :)

If you add the text in de modification.language.php files it will always work fine.
When you add the text hard in the subs.php it will always show the text youve added.
Please, don't PM me for support unless invited.
If you don't understand this, you will be blacklisted.

Augster

Hmm, I searched a bit and found Modifications.English.php under /Themes/default/languages/

Is this the file I would need to modify to include language-specific text strings in?

The mostly empty file cautions me to "please read the text at the top of index.english.php", but there are no apparent messages to would-be modifiers.

In the absence of any such directions, I am assuming to utilize the Modifications.language.php file, I would create unique variable names and assign a constant, then in the subs.php file, refer to those variables whenever I wish to display language-specific text, yes?

EDIT: Silly me, I was looking at the BOTTOM of the index.english.php, when I should have been reading the TOP

xenovanis

Add a new button in /Sources/Subs.php,

for example

// Home button
'homepage' => array(
'title' => $txt['homepage'],
'href' => '/',
'show' => true,
'icon' => '',
),


In the /Themes/default/languages/Modifcations.language.php files of all languages you use on your forum, add this

$txt['homepage'] = 'Homepage';


and translate Homepage to whatever you want in every different languagefile.
"Insanity: doing the same thing over and over again and expecting different results."

Augster

I figured something like that.

Well, I just tried modifying as suggested, adding this:

'homepage' => array(
'title' => $txt['homepage'],
'href' => "/",
'show' => true,
'icon' => "",
),

right above the 'home' button (so its first in the list).

Then added to Modifications... file:
$txt['homepage'] = "Home Page"

Uploaded both files to their respective locations on my website, and...

nuthin.  No changes.  Still exact same look.  I went to Admin->....->Languages... to kind force a refresh of the cache, but no-go.

Huh?

xenovanis

Change this


$txt['homepage'] = "Home Page"


to this

$txt['homepage'] = "Home Page';


I'm suprised that didn't throw up a parse error?
"Insanity: doing the same thing over and over again and expecting different results."

CapadY

Quote from: Augster on July 19, 2010, 04:44:34 PM
nuthin.  No changes.  Still exact same look.  I went to Admin->....->Languages... to kind force a refresh of the cache, but no-go.

When you use a cache system on your forum (that's default) you'll have to clear your forumcache before text edits are shown or you have to be real patient. Withouth clearing the cache it can take 24 hours before the edits are shown.

admin - maintenance - forum maintenance - Routine

Activate the last option, clearing the forum cache.

Please, don't PM me for support unless invited.
If you don't understand this, you will be blacklisted.

Augster

Gads...  that itty bitty thingy?

'k the squiggly thingy has been entered, saved, uploaded, forced refresh cached (or what I think is a forced refresh via the Admin route), AND.....

nuthin.  No changes.  Still exact same look.  No joy.  Tears in my eyes.

BUT THEN, I read a follow-on reply to clear the cache the PROPER way, via the Admin->Maintenance->Forum Maintenance->Routine, then selecting last item EMPTY THE FILE CACHE.

The angels of heaven rejoice, Hallelujah!

EDIT: NOW, if some kind soul could point out the proper way to add a hyperlink to my site logo (I replaced the SMF in the upper right with my own logo) without breaking it (do I simply add an href to code I see that places the logo?), that would conclude our course of study for today...

xenovanis

Nice work :)

For the logo, try this

/Themes/default/index.template.php, find

echo '
', empty($settings['site_slogan']) ? '<img id="smflogo" src="' . $settings['images_url'] . '/smflogo.png" alt="Simple Machines Forum" title="Simple Machines Forum" />' : '<div id="siteslogan" class="align_right">' . $settings['site_slogan'] . '</div>', '


replace with

echo '
', empty($settings['site_slogan']) ? '<a href="http://www.yoursite.com"><img id="smflogo" src="' . $settings['images_url'] . '/smflogo.png" alt="Simple Machines Forum" title="Simple Machines Forum" /></a>' : '<div id="siteslogan" class="align_right">' . $settings['site_slogan'] . '</div>', '
"Insanity: doing the same thing over and over again and expecting different results."

Security Professional Mag

Thanks this helped me as well...but their is a typo...

In one of the posts it show:

$txt['homepage'] = "Home Page';

and it should be

$txt['homepage'] = "Home Page";

I got a parsing error and saw that a ' was used instead of a ".


Advertisement: