Page 1 of 1

Current page url and theme configuration options

Posted: Mon Dec 11, 2006 3:49 am
by abdussamad
Hi

I have a few questions regarding templates.

How do you tell the url of the current page the user is viewing? I would like to be able to refer to this url in index.tpl or a theme's config.inc.php

How do you specify options for radio buttons in the theme configurator? select_values does not seem to work:

Code: Select all

$template_config = array(
    array(
        'var'           => 'header',
        'title'         => XYZ_HEADER,
        'description'   => XYZ_HEADER_DESCRIPTION,
        'type'          => 'radio',
        'default'       => "a",
        'select_values' => array("a"=>"a","b"=>"b")
    )

    
);
Thanks

Posted: Mon Dec 11, 2006 5:31 am
by carl_galloway
I can help with the radio button code

Code: Select all

    array(
        'var'           => 'header',
        'name'          => XYZ_HEADER,
        'description'   => XYZ_HEADER_DESCRIPTION,
        'type'          => 'radio',
	  'radio'         => array('value' => array('a', 'b'),
					'desc' => array('a', 'b')),
        'default'       => 'true',
    ),
As for the current url, I've been using the $view variable and other hacks within index.tpl, the Hemingway template demonstrates my approach, but if you figure out how to do this in config then I'll be interested in snatching your solution :D

Cheers

Carl

Posted: Mon Dec 11, 2006 11:42 am
by garvinhicking
Hi!

As for the URL, this should work:

Code: Select all

<a href="{$serendipityBaseURL}{$serendipityIndexFile}?{$uriargs}">Current URL</a>
HTH,
Garvin

Posted: Tue Dec 12, 2006 12:22 pm
by abdussamad
garvinhicking wrote:Hi!

As for the URL, this should work:

Code: Select all

<a href="{$serendipityBaseURL}{$serendipityIndexFile}?{$uriargs}">Current URL</a>
HTH,
Garvin
Hi Garvin

What about when url rewriting is in effect? How do I tell that url rewriting is in effect and how do I refer to the rewritten url?

Thanks

Posted: Tue Dec 12, 2006 12:30 pm
by garvinhicking
Hi!

The posted URL should work always, because it uses the fallback-URL mechanism that works on all s9y installations.

Using the rewritten URL would work if your template's config.inc.php simply assigns the $_SERVER['REQUEST_URI'] as a smarty variable and you use that one.

Regards,
Garvin

Posted: Tue Dec 12, 2006 5:34 pm
by abdussamad
$_SERVER['REQUEST_URI'] did the trick :). I wanted the url as the user sees it because that's what he's going to use when he customizes a theme's top nav bar in the admin backend. I wanted to be able to highlight the current page's entry in that nav bar. I've done that now and you should see a fresh theme release soon :wink:.

Carl and anybody else that is interested in how to refer to the current page url in config.inc.php can use this:

Code: Select all

$curpage="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

Posted: Tue Dec 12, 2006 5:39 pm
by carl_galloway
Nicely done, can't wait to see the new template.