Jump to content

Help with code to show title based on country url


shmideo

Recommended Posts

Hey guys

 

I have a basic sidebar callback form and I am trying to get it to show the form title and description depending on the country url, for example /en or /es, etc.

The code below shows the title specified in the WP widget which is "We can call you" and a line of description text.

I have an idea what to do but not sure, maybe set $display_description and $display_title and use elsif?

I realise I will have to have translated text for each language.

 

Thanks

shmideo

 

if($display_title || $display_description){
                $form_string .= "
                        <div class='gform_heading'>";
                if($display_title){
                    $form_string .= "
                  <h3 class='gform_title'>" . $form['title'] . "            </h3>";
                }
                if($display_description){
                    $form_string .= "
                            <span class='gform_description'>" . rgar($form,'description') ."</span>";
                }
                $form_string .= "
                        </div>";
            }
 

Thanks mentalist, this is MKII.

 

Took this off a previoust post, but the syntax is failing for last line but one (gravityform).

I have 9 callback forms and would like to add this to the WP sidebar.php so it would display the relevant 'form ID' relative to the URL. (/en, etc).

Think I'm close, maybe.

 

<?php
$pageURL = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];

if(preg_match("~/de/~",$pageURL)){
$page_language = "4";
}elseif(preg_match("~/it/~",$pageURL)){
$page_language = "5";
}elseif(preg_match("~/sv/~",$pageURL)){
$page_language = "6";
}elseif(preg_match("~/nb/~",$pageURL)){
$page_language = "7";
}elseif(preg_match("~/fr/~",$pageURL)){
$page_language = "8";
}elseif(preg_match("~/nl/~",$pageURL)){
$page_language = "9";
}elseif(preg_match("~/it/~",$pageURL)){
$page_language = "10";
}elseif(preg_match("~/es/~",$pageURL)){
$page_language = "3";
}elseif(preg_match("~/en/~",$pageURL)){
$page_language = "11";
}else{
$page_language ="2";
}

[gravityform id=.$page_language. title=true description=true];  **** failing sntax error ****
?>

 

Note, I manually tested [gravityform id=3 title=true description=true] in a wordpress page and it displayed the form ok,

Well I used this snippet to display a ribbon banner depending on the URL for the 9 languages, but I am not sure. The syntax is coming up in Dreamweaver.

The 9 forms have been set using gravityforms in WP and each has an ID. As it worked manually for one ID I'm thinking it should work dynamically?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.