|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
okidoki_howie Smarty Rookie
Joined: 16 May 2003 Posts: 8
|
Posted: Thu Jun 12, 2003 4:18 am Post subject: Where do u set your URL's? |
|
|
^, in the .php scripts or the .tpl templates?
I have long long long urls because of all the name value pair attibutes (but who doesn't=).
I've tried both ways. When i define/set them in the smarty templates they look incredible long and difficult to read. When i set them in the php scripts, it's a bit more easier since i use some custom function but then i have to pass the entire array of urls when the only difference between them may be one value (ex. category id).
To me, it seems more logical to define the urls in the templates since the responsibility is leaned towards the web designer and not the programmer.
What about you guys? Or is there a easier trick i can use? |
|
Back to top |
|
sweatje Smarty Regular
Joined: 17 Apr 2003 Posts: 70 Location: Bettendorf, Iowa, USA
|
Posted: Thu Jun 12, 2003 11:27 am Post subject: |
|
|
I usually send a tag for the base URL, and append as nescesarry. For situation where I know I will be having many vars that need to be updated and output every time, I will write a custom function.
HTH _________________ Jason
jsweat_php AT yahoo DOT com |
|
Back to top |
|
okidoki_howie Smarty Rookie
Joined: 16 May 2003 Posts: 8
|
Posted: Thu Jun 12, 2003 7:35 pm Post subject: |
|
|
sweatje wrote: | I usually send a tag for the base URL, and append as nescesarry. For situation where I know I will be having many vars that need to be updated and output every time, I will write a custom function.
HTH |
ic... Thanks for the response sweatje. Can you tell me more about the custom function, exactly what does it do? Your talkin about a function in php and not in smarty rite? |
|
Back to top |
|
sweatje Smarty Regular
Joined: 17 Apr 2003 Posts: 70 Location: Bettendorf, Iowa, USA
|
Posted: Thu Jun 12, 2003 7:39 pm Post subject: |
|
|
[php:1:a1fd7512a7]<?php
$smarty->register_function('appl_url', 'smarty_appl_url');
/**
* function to write an application url
*
* makes the assumption that anything not explicitly overridden should remain the default
* @return void
*/
function smarty_appl_url($paParms, &$poSmarty)
{
global $go_controller;
$a_slice = $go_controller->GetSlices();
if (array_key_exists('view', $paParms)) {
$s_view = $paParms['view'];
} else {
$s_view = $go_controller->GetView();
}
for ($i=1; $i<4; $i++) {
$s_idx = 'c'.$i;
$s_var = 's_'.$s_idx;
$$s_var = "&$s_idx=";
if (array_key_exists($s_idx, $paParms)) {
$$s_var .= $paParms[$s_idx];
} else {
$$s_var .= $a_slice[$s_idx];
}
$s_idx = 'v'.$i;
$s_var = 's_'.$s_idx;
$$s_var = "&$s_idx=";
if (array_key_exists($s_idx, $paParms)) {
$$s_var .= $paParms[$s_idx];
} else {
$$s_var .= $a_slice[$s_idx];
}
}
//some year stuff later
print APPL_BASE.$s_view.$s_c1.$s_v1.$s_c2.$s_v2.$s_c3.$s_v3;
}
?>[/php:1:a1fd7512a7] _________________ Jason
jsweat_php AT yahoo DOT com |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|