• Welcome to PHPVIBE Forums. Please log in.

[ Video Sharing CMS v4 ] User Friendly URL for translations

Started by Rafa,

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

RafaTopic starter

I am looking to add to my website the following option, once translated:

http://website.com/en - for English
http://website.com/es - for Spanish
http://website.com/pt - for Portuguese

Right now, after translating get "&clang=en" and the language specification is no longer displayed in the URL. Can you help achieve the scenario above? Thanks in advance.

Rafa
  •  

Marius P.

Hi! The url router would have to be changed fully, it is based on component/module/position, you can't just easily code it to keep the lang in url.
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

RafaTopic starter

Yeah, It thought so...
On top of creating a cool site with phpVibe, I have been learning a lot from the code you guy put together, so is it asking too much for you to give me a few pointers in the right direct? I would be really cool have an idea on how that is done.
  •  

Marius P.

Hi,
open lib/router.php and check the helper functions on top (those will show you all there is to know about routing in PHPVibe).

com() -> returns component name (for example)

For example if you have /mario/likes/php/code
$router->fragment(0) = > mario
$router->fragment(1) = > likes
$router->fragment(2) = > php
$router->fragment(3) = > code

Hope this helps? If you have any specific question, please ask.
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

RafaTopic starter

Hi Mario,
Once you have used com() to retrieved the component name, how do you determine what the correct url should be? Could you give me an example of a real PHPVibe scenario?
  •  

Marius P.

Hi, see index.php
// Let's start the site
$page = com();
$id_pos = null;
//Decide what to load
if(!$page)   {
$com_route = ABSPATH."/com/com_home.php";
$canonical = site_url();
} else {
// Define wich page to load
switch($page){
   case video:
      $com_route = ABSPATH."/com/com_video.php";      
      break;
    case videos:
      $com_route = ABSPATH."/com/com_videolist.php";      
      break;         
   case profile:
      $com_route = ABSPATH."/com/com_profile.php";      
      break;      
   case note:
      $com_route = ABSPATH."/com/com_note.php";         
      break;      
    case channel:
      $com_route = ABSPATH."/com/com_channel.php";      
      break; 
    case channels:
      $com_route = ABSPATH."/com/com_channels.php";      
      break; 
   case playlist:
      $com_route = ABSPATH."/com/com_playlist.php";         
      break;   
    case show:
      $com_route = ABSPATH."/com/com_search.php";      
      break;   
   
   case me:
      $com_route = ABSPATH."/com/com_manager.php";      
      $reqform = true;
      break;
    case buzz:
      $com_route = ABSPATH."/com/com_buzz.php";      
      $reqform = true;
      break;      
   case share:
      $com_route = ABSPATH."/com/com_share.php";      
      $reqform = true;
      break;
   case add:
      $com_route = ABSPATH."/com/com_add.php";      
      $reqform = true;
      break;
   case upmusic:
      $com_route = ABSPATH."/com/com_music.php";      
      $reqform = true;
      break;
    case upimage:
      $com_route = ABSPATH."/com/com_image.php";      
      $reqform = true;
      break;      
    case subscriptions:
      $com_route = ABSPATH."/com/com_subscriptions.php";      
      break;   
    case "login":
      $com_route = ABSPATH."/com/com_login.php";      
      break;   
    case "register":
      $com_route = ABSPATH."/com/com_register.php";      
      break;
   case page:
      $com_route = ABSPATH."/com/com_page.php";      
      break;   
   case blog:
      $com_route = ABSPATH."/com/com_blog.php";      
      break;
   case blogcat:
      $com_route = ABSPATH."/com/com_blogcat.php";      
      break;   
    case blogpost:
      $com_route = ABSPATH."/com/com_post.php";      
      break;      
    case "forward":
   redirect(start_playlist());   
   break;
   default:
       $com_route = ABSPATH."/com/com_404.php";      
       $canonical = site_url();
      break;   
}
//end switch coms
}
//end if com()



It uses case to match existing components.
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

RafaTopic starter

Hi Mario,
I am still a bit confused over how these things are coming together, but I think I am getting there.
Question... if I wanted to show in the URL the "main" folder at all times (e.g. home ->domain.com/main, Channel -> domain.com/main/channel...). How would I do that?

Perhaps, if I understand how the code is "hiding" the main folder I can wrap my head around this. And what about .htaccess file? what kind of role doe it have over this subject?

Thanks for the support.
  •  

Marius P.

I'm not sure what's the 'main' folder and what do you want to say with that?
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

RafaTopic starter

It is the actual name of the folder that holds all files users interact with.
The path goes /tpl/main

I am referring to this "main" folder.

Does it make sense now?
  •  

Marius P.

That folder holds the themes, the functionality is different http://www.phpvibe.com/understanding-the-phpvibe-functional-flow/
Does not load directly anything from there via rooter.
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

Similar topics (7)