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>";
            }
 

Link to comment
Share on other sites

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,

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.