Jump to content
gcoppola7

Using URL in boxes and feature with Qtranslate

Recommended Posts

gcoppola7
Hi
I’m using PagelinePro theme for a page i'm building: www.americasblindspot.com .
it's a bilingual site, spanish and english, using the Qtranslate
plugin, that works great for titles and texts, but I don't know how to add code so that the the URLs I add in the boxes and features redirects to the appropriate language page.
Example: I switch my page to Spanish, and all the text is indeed translated correctly. But when I clik on a feature or box link, it redirects back to the English version of that page.
Can i included anything in the field “Feature Link URL: Adding a URL here will add a link to your feature slide-Enter Feature Link URL” so that it will send me to the Spanish version?
Thanks in advance

Share this post


Link to post
Share on other sites
Simon
Add the following to platformbase/functions.php

[CODE]
function add_lang_features($metadata, $object_id, $meta_key, $single){
if ( function_exists( 'qtrans_getLanguage' ) && isset($meta_key) && 'feature-link-url' === $meta_key) {

return sprintf( '%s?lang=%s', $metadata, qtrans_getLanguage() );
}
return $metadata;
}
add_filter('get_post_metadata', 'add_lang_features', true, 4);
[/CODE]

Share this post


Link to post
Share on other sites
gcoppola7
Ok. I did something wrong.
From the editor in appearance, I selected the platformbase theme to edit. I opened function.php and on the bottom i pasted what you sent. But nothing happened.
did i do something wrong?

Share this post


Link to post
Share on other sites
Simon
You probably dont have the platformbase theme activated. Also strongly advise against using the wp theme/plugin editor, its BAD, always edit files with FTP

Share this post


Link to post
Share on other sites
gcoppola7
thanks for the advice. I went through my ftp platformbase/functions.php and pasted what you sent, and still doesn't work.
any ideas?

Share this post


Link to post
Share on other sites
Simon
[quote][color=#282828][font=helvetica, arial, sans-serif]You probably dont have the platformbase theme activated[/font][/color][/quote]

Go to Appearance/themes and activate the child theme.

Share this post


Link to post
Share on other sites
gcoppola7
I appreciate your patience. I'm a bigger obviously. But in any case, I activated platformbase. It deactivated the pro, or at least it shows as needing reactivating, deactivated all my widgets and sidebars, and it's still not redirecting me to the correct language page.
everything that is deactivated with platformbase theme is reconfigured when i reactivate the platformpro.

Share this post


Link to post
Share on other sites
Simon
Well the code will only run when platformbase is activated, yes widgets and menus may need re-adding, they are stored on a theme by theme basis.

Its up to you if you want to use it, i tested the code, it works 100%

Share this post


Link to post
Share on other sites
gcoppola7
OK. I re-added all now that pagelinesbase is activated. page looks as before, minus a tweak here and there, but it's still not directing me to the right pages. i don't doubt the code is 100% funcional, but I don't know what i'm doing wrong:
i included the code in pagelinesbase/functions via FTP, I activated pagelinesbase theme is appearance, i double checked all of the above...

Share this post


Link to post
Share on other sites
Simon
I'm looking into it.

Share this post


Link to post
Share on other sites
Simon
OK it was slightly more complicated ;)

revised code.

[CODE]
function add_lang_features($metadata, $object_id, $meta_key, $single){

if ( ! is_admin() && function_exists( 'qtrans_getLanguage' ) && isset($meta_key) && 'feature-link-url' === $meta_key) {
remove_filter( 'get_post_metadata', 'add_lang_features', 999, 4 );
$data = get_post_meta( $object_id, 'feature-link-url' );
$link = sprintf( '%s/?lang=%s', $data[0], qtrans_getLanguage() );
add_filter('get_post_metadata', 'add_lang_features', 999, 4);
return $link;
}
return $metadata;
}
add_filter('get_post_metadata', 'add_lang_features', 999, 4);
[/CODE]

Share this post


Link to post
Share on other sites
gcoppola7
Hmmmm. Still not working. I replaced with the new code in the pagelinesbase/functions, and I confirmed the code code was actually changed. But still nothing. should i be adding something in the actual box to write the URL in each box and feature?
Thanks for your patience and insistance

Share this post


Link to post
Share on other sites
Simon
Well yea, each feature will need a link, the filter just adds ?lang=xx to the end of the url

Share this post


Link to post
Share on other sites
gcoppola7
Sorry, i didn't explain myself. Of course all boxes and features have a link. But none of them have the ?lang=xx ending... the filter is not working...

Share this post


Link to post
Share on other sites
Simon
I have it working here, can you screenshot the feature settings for the feature on the home page

Share this post


Link to post
Share on other sites
gcoppola7
OK. It's very small, so let me know if you can see all of it.

Share this post


Link to post
Share on other sites
Simon
[quote name='gcoppola7' timestamp='1349887095' post='131150']
OK. It's very small, so let me know if you can see all of it.
[/quote]
Its small alright, where is it? lol

Share this post


Link to post
Share on other sites
gcoppola7
so sorry....
http://imgur.com/BpXhG
and
http://imgur.com/XKDTP

Share this post


Link to post
Share on other sites
Simon
What are you trying to do? have you uploaded the images somewhere? imgur.com is easy

Share this post


Link to post
Share on other sites
gcoppola7
so sorry....
http://imgur.com/BpXhG
and
http://imgur.com/XKDTP

Share this post


Link to post
Share on other sites
Simon
OK so what is the link? I cant actually see it, the feature link that is.

Share this post


Link to post
Share on other sites
gcoppola7
feature: http://www.americasblindspot.com/chavez-renews-oil-mandate/
same for the box of course

Share this post


Link to post
Share on other sites
Simon
The script is adding an extra / into the url either remove it in the script, or remove it from the url in the feature.

Share this post


Link to post
Share on other sites
gcoppola7
Almost there.
I erased directly in the link and the feature is working perfectly. Thank you so much.
The boxes though still don't work, even after I took the extre / from the link like with the features.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Similar Content

    • janpeeters
      By janpeeters
      Over the last month I had extensive communications with the developer of the (premium) Anything Boxes section (in Pagelines store) (Adam Munns) and the developer of the WP Polylang Multilingual plugin (Frederic Demarle).
       
      This was because the following problem occurred:
      Anything Boxes showed all posts of two languages (Dutch and English) on the respective static frontpages for each language. It should of course have filtered posts for Dutch language on the Dutch frontpage and English on the English frontpage.
       
      The solution to this problem was simple in the end. When duplicating a page for use in another language the settings for Anything Boxes were not copied to the new page and I should have set these settings manually again on the new page. I wasn't aware of this, but it makes sense. Because of this the pages didn't know how to differentiate between posts from different languages.
       
      The dev of Polylang told me that Polylang is currently smart enough to synchronize metas like Featured images and page templates but it does not work out of the box with metas created by plugins and themes but (according to Frederic) it is rather easy to add them in the list using the filter 'pll_copy_post_metas'.
      He mentions that he is not sure that these 'PageLines Meta Settings' are stored in post meta but that would make sense according to him. He asks if the Pagelines dev team will be interested to support this feature in the future.
       
      I'm also wondering if you will consider adding Polylang translation support for manually editable strings like the 'Read more…' strings in Pagelines Settings.
       
      Well that's of course up to you but I thought to let you know to be able to take this into consideration. I also post this for other users in case they experience the same kind of trouble and are looking for an answer.
       
      Best regards,
      Jan Peeters
    • bankrollbuilder
      By bankrollbuilder
      I used a custom hook to put a banner ad in my header. It works but its not in the right position. it is centered and above my logo and I would like to float it to the right of my logo in the header. heres the link: http://shaboopie.com/shaboopie-wp/free-logos-pg1/

      thanks.

      Dan B.
    • starlit
      By starlit
      Can one have two hero sections on one page?

      I want a landing page which leads/advertises two subpages.

      Or is there another option?

      Please help.

      THANK YOU
    • hutruk
      By hutruk
      Hi!

      I am using the shortcodes for tabs, as described in the documentation.

      When I insert the following code:


      [pl_tabs][pl_tabtitlesection type="tabs"] [pl_tabtitle number="1"]Title 1[/pl_tabtitle] [pl_tabtitle number="2"]Title 2[/pl_tabtitle] [/pl_tabtitlesection] [pl_tabcontentsection] [pl_tabcontent active="yes" number="1"] Lorem ipsum dolor sit amet, consectetur adipiscing elit [/pl_tabcontent] [pl_tabcontent number="2"] Lorem ipsum dolor sit amet, consectetur adipiscing elit [/pl_tabcontent] [/pl_tabcontentsection] [/pl_tabs]

      I get a strange output (in the attachment).

      Any ideas?

      Thanks in advance!

    • MooiWeb
      By MooiWeb
      Hello,

      I would like to align my qtranslate with my breadcrumb so that the flags are on the same hight.
      I'm aware of putting a code in the custom css and tryed severall codes from your site but for now, no succes

      The site i'm working on is http://nieuw.vazdias.nl

      Thx,
      Edwin



×