Leaderboard ad per language

Posted in: Newspaper
Post count: 52

Hi guys,

I’d like to use the Header Ad section to display a 728×90 image. For now I’ve used the theme options panel to display the first of the images.

Works fine in the first language, English, but as the site has two other language settings, I need this image to change dependent on language, i.e. to be replaced by the image in language two or language three when the switch is made by the user.

Is there a way of achieving this in the template header-style-2.php?

Thanks

Post count: 3343

Hi,
You can do it with a condition there when is that language 1 show a banner, if language 2 show that banner, etc.

You need to find on Google how to put condition with you language plugin.

What plugin do you use for switching the language?

Thanks!

Post count: 52

Hi Marius

I’m using WPML. Have tried the following in my functions

function hash_header_image_switcher() {
 
switch(ICL_LANGUAGE_CODE){
 
	case 'en':
	$link_to_image = 'top-header-en.png';
	break;
	 
	case 'fi':
	$link_to_image = 'top-header-fi.png';
	break;
	 
	case 'sv':
	$link_to_image = 'top-header-sv.png';
	break;
	 
	return $link_to_image;
	}
}

and then added this in to header-style-2:
<?php echo "<img src=" . hash_header_image_switcher() . " />";?>

but it’s not working.

Any ideas?

Post count: 3343

Hi,
You need to check and see if the image link is correct, is not sufficient to put only the image file, that image should have a path, or images are hosted in site root?

The code seems fine.

Thanks!

Post count: 52

Hi Marius,

Have tried all combinations mate. The simplest was to put images in child theme folder and reference files from there.

Currently I have the path as ‘images/top-header-fi.png’; and still no joy. Is there any way of overriding the template that’s being loaded? Not sure what’s up as it should be pretty simple.

Cheers
Hash

Post count: 3343

Hi,
Can you check with inspector to see if the image are there and have the correct path.
Can you give me a link to inspect it myself?

Thanks!

Post count: 52

Hi Marius,

Here’s a link to the demo version of the site: demo.demofinland.org

The Header file is working fine, just not loading the images.

Currently my images folder is in the same directory as my WP install… http://demo.demofinland.org/images/…still can’t get to it. Not sure what I’m doing wrong. Have tried absolute and relative paths.

Hope we can get a resolve soon…
Cheers

Post count: 3343

Hi,
You have the incorrect path files.

Use the full path like: http://demo.demofinland.org/images/top-header-en.png and the code will be $link_to_image = 'http://demo.demofinland.org/images/top-header-en.png'; and change for each language case.

Thanks!

Post count: 52

Hi,

That’s exactly what I tried first…I now have:

function header_image_switcher() {
 
switch(ICL_LANGUAGE_CODE){
 
	case 'en':
	$link_to_image = 'http://demo.demofinland.org/images/top-header-en.png';
	break;
	 
	case 'fi':
	$link_to_image = 'http://demo.demofinland.org/images/top-header-fi.png';
	break;
	 
	case 'sv':
	$link_to_image = 'http://demo.demofinland.org/images/top-header-sv.png';
	break;
	 
	return $link_to_image;
	}
}

The Header style 1 template has:

<div class="span8 td-header-style-1">
                <?php
                // show the header ad spot
                /* echo td_global_blocks::get_instance('td_ad_box')->render(array('spot_id' => 'header')); */
                echo "<img src=" . header_image_switcher() . " />";
                ?>
            </div>
        </div>

And all I get in the inspector is:

<div class="span8 td-header-style-1">

    <img src="/"></img>

</div>

I know the code is fine and the language plugin is working great…could it be something else?

Cheers

Post count: 3343

Hi,
You need to check if that ICL_LANGUAGE_CODE return something. Are you sure this is corent: switch(ICL_LANGUAGE_CODE) if this return nothing there will be no case for language and the function return nothing.

Also you can try to add this on the switch and see if the function to return any language to get the default value. ANd if this work probably that ICL_LANGUAGE_COD doesn’t return the language.

default:
$link_to_image = 'http://demo.demofinland.org/images/top-header-en.png';
break;

Hope this help!
Thanks!

Viewing 10 posts - 1 through 10 (of 10 total)
The forum ‘Newspaper’ is closed to new topics and replies.