Welcome to Geeklog, Anonymous Friday, November 08 2024 @ 08:40 pm EST

Geeklog Forums

URL rewrite + parameters


Status: offline

alb3rt

Forum User
Regular Poster
Registered: 10/30/06
Posts: 71
Location:Mexico City
Is it possible to get parameters using a URL rewrite? I mean:

Text Formatted Code

my_site/page/page1
 


I want to get "page1"

Thanks,
D Web Studio - www.d-webstudio.net
 Quote

Status: offline

alb3rt

Forum User
Regular Poster
Registered: 10/30/06
Posts: 71
Location:Mexico City
What I have solved:

Modifying .htaccess

Text Formatted Code

    #RewriteRule ^(.*)$ /index.php/$1 [L]
    RewriteRule ^page/(.*)$  /staticpages/index.php?page=$1 [L,QSA]
 


But with this, url rewrite does not work with all other parts that are not declared in the .htaccess
D Web Studio - www.d-webstudio.net
 Quote

Status: offline

Laugh

Site Admin
Admin
Registered: 09/27/05
Posts: 1470
Location:Canada
>>Is it possible to get parameters using a URL rewrite? I mean:

In what way? In the code the url.class.php figures out the arguments (it is what is being referred to as the variables). COM_setArgNames returns the names for the plugin that uses rewrite.
One of the Geeklog Core Developers.
 Quote

Status: offline

alb3rt

Forum User
Regular Poster
Registered: 10/30/06
Posts: 71
Location:Mexico City
In this case get id page from the url, What I need is to insert an image in the staticpage (using ?page= ), this works for me when I don't use url rewrite.

Text Formatted Code
my_site/staticpages/index.php?page=PAGE_ID

$page_ID = Geeklog\Input::request('page', '');


But using URL Routing, I can't get $page_ID
D Web Studio - www.d-webstudio.net
 Quote

Status: offline

Laugh

Site Admin
Admin
Registered: 09/27/05
Posts: 1470
Location:Canada
I don't have my Geeklog development server setup at the moment to test but looking at the code the Static Page plugin supports URL Rewriting and grabs the page variable like this:

Text Formatted Code

COM_setArgNames(array('page', 'disp_mode'));
$page = COM_applyFilter(COM_getArgument('page'));
 

One of the Geeklog Core Developers.
 Quote

Status: offline

alb3rt

Forum User
Regular Poster
Registered: 10/30/06
Posts: 71
Location:Mexico City
Your answer has solved the problem, I create my "carousel" from lib-custom. Big Grin

Text Formatted Code

function CUSTOM_templateSetVars($templatename, $template)

...

    if (COM_onFrontpage()) {
        $tid = 'home';
        $full = true;
    } else {
        COM_setArgNames(array('page', 'disp_mode'));
        $tid = COM_applyFilter(COM_getArgument('page'));
    }
   $carousel = DWS_Carousel($tid, $full);

...
    switch ($templatename) {
        case 'header':
            $template->set_var('carousel', $carousel);
            break;
...
 


I avoid touching geeklog core.


Thank you very much!
D Web Studio - www.d-webstudio.net
 Quote

All times are EST. The time is now 08:40 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content