Post by redelevencreative » Sat Mar 14, 2015 3:43 am

Hi there

Up until this point I have always hard coded links to info pages and the like onto the template. Maybe some in header and some in footer etc...all exactly where I want them to appear.

However, I've just done my first opencart site with 2 languages and quickly found out when a user changes to German, for example, nothing changes obviously on these hard coded parts.

So...my question is...how do I add a link to template without hard coding it?

Issue number 2 is when I have placed a strapline on a site...let's say I've added the words 'build, belong, believe' in the header template next to logo...this is obviously hard coded too...so how can I added these words so they are translated? Do I create a new language string for example?

Many thanks in advance

Gav

New member

Posts

Joined
Fri Sep 21, 2012 5:50 am

Post by viethemes » Sat Mar 14, 2015 8:36 pm

First, you can go to each language file, for example: catalog\language\english\default.php, add texts you want to translate at the end of the file

Code: Select all

$_['text_my_work'] = 'My Work';
$_['text_my_projects'] = 'My Projects';
After that, you edit the header.tpl file, and translated text by this code:

Code: Select all

<?php global $language; echo $language->get('text_my_work'); ?>
So texts will be translated when switch to other language.

http://www.viethemes.com - OpenCart turtorials, news, tips and stricks, extension

Our extensions:
Visual Theme Editor - Powerful tool for customizing style of any theme visually
Live Theme Editor - Customize layout, colors, backgrounds, fonts of the default theme
Theme Animation - Animation Editor for any theme

Extra Positions PRO, Custom JavaScript, Custom CSS and others


User avatar
Active Member

Posts

Joined
Thu Jan 08, 2015 12:17 pm


Post by redelevencreative » Sat Mar 14, 2015 8:42 pm

That sounds perfect thanks.

Just need to figure out adding information pages into template without hard coding then.

Thanks

New member

Posts

Joined
Fri Sep 21, 2012 5:50 am

Post by redelevencreative » Sat Mar 14, 2015 9:09 pm

So 1 last thing is:

What code do I need to place on template to call in..

A Specific info page (lets say ID 3)
But...not hard code the text between the link to ID3...as otherwise it won't work with other languages

Need the trigger text to pick up my 2nd language (German)

If anyone can give some pointers that would be great.

Thanks

New member

Posts

Joined
Fri Sep 21, 2012 5:50 am

Post by viethemes » Sun Mar 15, 2015 1:42 am

You can try this code:

Code: Select all

<?php global $url; echo $url->link('information/information', 'information_id=1'); ?>
Note that change information=1 to your ID you want to add.

http://www.viethemes.com - OpenCart turtorials, news, tips and stricks, extension

Our extensions:
Visual Theme Editor - Powerful tool for customizing style of any theme visually
Live Theme Editor - Customize layout, colors, backgrounds, fonts of the default theme
Theme Animation - Animation Editor for any theme

Extra Positions PRO, Custom JavaScript, Custom CSS and others


User avatar
Active Member

Posts

Joined
Thu Jan 08, 2015 12:17 pm


Post by redelevencreative » Sun Mar 15, 2015 2:22 pm

Ah great thanks...but if I am hard coding the word 'link' what happens in the second language?

Thanks
Gavin

New member

Posts

Joined
Fri Sep 21, 2012 5:50 am

Post by viethemes » Sun Mar 15, 2015 2:29 pm

redelevencreative wrote:Ah great thanks...but if I am hard coding the word 'link' what happens in the second language?

Thanks
Gavin
You should try to follow the above solution: http://forum.opencart.com/viewtopic.php ... 18#p549652

http://www.viethemes.com - OpenCart turtorials, news, tips and stricks, extension

Our extensions:
Visual Theme Editor - Powerful tool for customizing style of any theme visually
Live Theme Editor - Customize layout, colors, backgrounds, fonts of the default theme
Theme Animation - Animation Editor for any theme

Extra Positions PRO, Custom JavaScript, Custom CSS and others


User avatar
Active Member

Posts

Joined
Thu Jan 08, 2015 12:17 pm


Post by redelevencreative » Sun Mar 15, 2015 2:41 pm

Ok but in each info page I can already have

English title
German title

So can't these be drawn in to create the link text?

Rather than creating a language string

Thanks

New member

Posts

Joined
Fri Sep 21, 2012 5:50 am

Post by viethemes » Sun Mar 15, 2015 10:33 pm

It is hard to display title of information like that. You should use the above solution :)

http://www.viethemes.com - OpenCart turtorials, news, tips and stricks, extension

Our extensions:
Visual Theme Editor - Powerful tool for customizing style of any theme visually
Live Theme Editor - Customize layout, colors, backgrounds, fonts of the default theme
Theme Animation - Animation Editor for any theme

Extra Positions PRO, Custom JavaScript, Custom CSS and others


User avatar
Active Member

Posts

Joined
Thu Jan 08, 2015 12:17 pm

Who is online

Users browsing this forum: No registered users and 4 guests