Jump to content


Photo
Resolved

Using URL in boxes and feature with Qtranslate



  • This topic is locked This topic is locked
34 replies to this topic

#1 gcoppola7

gcoppola7

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts
  • Country: Country Flag

Posted 10 October 2012 - 11:33 AM

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

#2 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 10 October 2012 - 01:47 PM

Add the following to platformbase/functions.php

 
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);


#3 gcoppola7

gcoppola7

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts
  • Country: Country Flag

Posted 10 October 2012 - 02:07 PM

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?

#4 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 10 October 2012 - 02:10 PM

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

#5 gcoppola7

gcoppola7

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts
  • Country: Country Flag

Posted 10 October 2012 - 02:22 PM

thanks for the advice. I went through my ftp platformbase/functions.php and pasted what you sent, and still doesn't work.
any ideas?

#6 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 10 October 2012 - 02:23 PM

You probably dont have the platformbase theme activated


Go to Appearance/themes and activate the child theme.

#7 gcoppola7

gcoppola7

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts
  • Country: Country Flag

Posted 10 October 2012 - 02:38 PM

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.

#8 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 10 October 2012 - 02:40 PM

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%

#9 gcoppola7

gcoppola7

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts
  • Country: Country Flag

Posted 10 October 2012 - 03:05 PM

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

#10 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 10 October 2012 - 03:36 PM

I'm looking into it.

#11 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 10 October 2012 - 03:50 PM

OK it was slightly more complicated ;)

revised 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);


#12 gcoppola7

gcoppola7

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts
  • Country: Country Flag

Posted 10 October 2012 - 04:07 PM

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

#13 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 10 October 2012 - 04:08 PM

Well yea, each feature will need a link, the filter just adds ?lang=xx to the end of the url

#14 gcoppola7

gcoppola7

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts
  • Country: Country Flag

Posted 10 October 2012 - 04:25 PM

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

#15 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 10 October 2012 - 04:27 PM

I have it working here, can you screenshot the feature settings for the feature on the home page

#16 gcoppola7

gcoppola7

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts
  • Country: Country Flag

Posted 10 October 2012 - 04:38 PM

OK. It's very small, so let me know if you can see all of it.

#17 gcoppola7

gcoppola7

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts
  • Country: Country Flag

Posted 10 October 2012 - 04:39 PM

and once of the boxes

#18 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 10 October 2012 - 04:39 PM

OK. It's very small, so let me know if you can see all of it.

Its small alright, where is it? lol

#19 gcoppola7

gcoppola7

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts
  • Country: Country Flag

Posted 10 October 2012 - 04:43 PM

so sorry....

and


#20 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 10 October 2012 - 04:44 PM

What are you trying to do? have you uploaded the images somewhere? imgur.com is easy





Also tagged with one or more of these keywords: Resolved