4images Forum & Community
4images Modifications / Modifikationen => Templates & Styles (Requests & Discussions) => Topic started by: uae on August 04, 2002, 07:50:54 AM
-
Hi,
I've got more than one template, and I was wondering if I can have a link or a drop down list of all the templates I've got and let my visitors to 4images choose between templates.
-
:D
Grrrr8 news, check this out, I've got this done I guess...
Now any visitor to your 4images can select between templates.
http://www.myuae.com/myalbum/
+++++++++++++
-
Wow that is great, that´s what I need!
Can you post the instructions or the code, that I can realize this function in my gallery?
Thx & greets Daniel
-
Here is what you need to do,
first,
find the following in the global.php
//-----------------------------------------------------
//--- Generate Setting --------------------------------
//-----------------------------------------------------
$sql = "SELECT setting_name, setting_value
FROM ".SETTINGS_TABLE;
$result = $site_db->query($sql);
if (!$result) {
echo $lang['no_settings'];
exit;
}
while ($row = $site_db->fetch_array($result)) {
$config[$row['setting_name']] = $row['setting_value'];
}
$site_db->free_result();
Then add the following
// registering global variable "user_template"
if (!isset($user_template))
session_register("user_template");
// check global variable for Empty
if ($user_template=="" || empty($user_template))
$user_template = $config['template_dir'];
// set the Template if QueryString is not nothing
if (!empty($t) || $t != "")
$user_template = $t;
$config['template_dir'] = $user_template;
it should look like this.
//-----------------------------------------------------
//--- Generate Setting --------------------------------
//-----------------------------------------------------
$sql = "SELECT setting_name, setting_value
FROM ".SETTINGS_TABLE;
$result = $site_db->query($sql);
if (!$result) {
echo $lang['no_settings'];
exit;
}
while ($row = $site_db->fetch_array($result)) {
$config[$row['setting_name']] = $row['setting_value'];
}
[b]// registering global variable "user_template"
if (!isset($user_template))
session_register("user_template");
// check global variable for Empty
if ($user_template=="" || empty($user_template))
$user_template = $config['template_dir'];
// set the Template if QueryString is not nothing
if (!empty($t) || $t != "")
$user_template = $t;
$config['template_dir'] = $user_template;
[/b]
$site_db->free_result();
The second thing, I've created a new php page with two forms of drop down list, one form was for the languages, and the other was for the templates, then I included this page to every template's header file.
This is the new php file I've created.
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="640" align="center">
<tr>
<form>
<td width="50%" align="left">
<select name="select_template" onChange="javascript:if(options[selectedIndex].value!='0') document.location.href=options[selectedIndex].value; ">
<option value="0">Select a Template</option>
<?php
$t_link = $_SERVER['QUERY_STRING'];
$t_link = preg_replace("/&{0,1}l=[a-z\.]{1,25}/", "", $t_link);
$t_link = "?".$t_link;
$t_link = $_SERVER['PHP_SELF'].$t_link."&t=";
$folderlist = array();
$handle = opendir(ROOT_PATH."templates");
while ($folder = @readdir($handle)) {
if (@is_dir(ROOT_PATH."templates/$folder") && $folder != "." && $folder != ".." && $folder != "_vti_cnf" ) {
$folderlist[] = $folder;
}
}
closedir($handle);
foreach ($folderlist as $folder) {
$templink = $t_link.$folder;
?>
<option value="<?php echo $templink; ?>"><? echo $folder ?></option>
<?php
}
?>
</select>
</td>
</form>
<form>
<td width="50%" align="right">
<select name="select_language" onChange="javascript:if(options[selectedIndex].value!='0') document.location.href=options[selectedIndex].value; ">
<option value="0">Select a Language</option>
<?php
$l_link = $_SERVER['QUERY_STRING'];
$l_link = preg_replace("/&{0,1}l=[a-z\.]{1,25}/", "", $l_link);
$l_link = "?".$l_link;
$l_link = $_SERVER['PHP_SELF'].$l_link."&l=";
$folderlist = array();
$handle = opendir(ROOT_PATH."lang");
while ($folder = @readdir($handle)) {
if (@is_dir(ROOT_PATH."lang/$folder") && $folder != "." && $folder != ".." && $folder != "_vti_cnf" ) {
$folderlist[] = $folder;
}
}
closedir($handle);
foreach ($folderlist as $folder) {
$langlink = $l_link.$folder;
?>
<option value="<?php echo $langlink; ?>"><? echo $folder ?></option>
<?php
}
?>
</td>
</form>
</tr>
</table>
Please do report bugs to me.
Good Luck
-
Hello,
I´ve tried to install your Mod to my gallery, but it dodn´t work. OK I´m an absolut beginner in PHP.
First I change the code in the global.php, then I create an new page, called choice.php wirh the two forms. Here is my first questuion:
In which folder must the choise.php? /4images or /4images/includes ??? I think here is my mistake!
Then I want to include the forms only in the member_editprofile.html I open the member_editpofile.html in the template folder und use the following code:
<?php
include("http://www.papierbrinkmann.de/umleitung/4images/choice.php");
?>
Where is my fault? Have I something forgot?
Thanks & Greets
Daniel
-
Hi there,
Sorry, I haven't mentioned this, but I have placed the php file with the forms under the templates dir.
in your case, 4images/templates/choise.php
Good Luck.
-
Hi uae,
I´ve change the global.php und copy the code for the forms in extra file called choice.php.
This file I´ve put in the template directory, but in the forms I can´t find the different template-styles or language!
Here is the url:
http://www.papierbrinkmann.de/umleitung/4images/templates/choice.php
Is my MySQL Version to old or where is the vault?
Greets Daniel
-
Hello,
where is the mistake? I see this:
Warning: open(/tmp\sess_932754823532583625, O_RDWR) failed: m (2) in g:\myserver\4images\global.php on line 141
and this for 3 times:
Warning: Cannot add header information - headers already sent by (output started at g:\myserver\4images\global.php:141) in g:\myserver\4images\includes\sessions.php on line 85
Line 141 in global.php= session_register("user_template");
Line 85 in sessions.php= setcookie($cookie_name, $value, $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
I can see the forms and select a template, it works. But what about the errors?
Can you help me?
-
Hi,
good smal and easy mod. :P
I use it with links in my galley to change the styles !!
Th
Gruss
Kurt
-
@ KurtW
did you use it at the moment on any homepage?? where we can visit it??
because i made this codechanges BUT the only thing i see is the select box with the text "Select a Template/ Language" ?!!!
No Folders/ templates to change?!!!
Please help?!!!
Thanks Tusnelda99
-
@ KurtW
did you use it at the moment on any homepage?? where we can visit it??
Hi Tusnelda99
no, i dont use this Mod yet.
I mad a update form my site and delete this option for Users:
But here was my code from the script:
<script language="JavaScript">
<!--
function goto_site() {
var selectedIndex = document.form1.to.selectedIndex;
if (selectedIndex > 0) {
var selection = document.form1.to.options[selectedIndex].value;
parent.location=selection;
}
}
//-->
</script>
<form method="post" action name="form1">
<select name="to" size="1" onchange="goto_site();" class="button">
<option selected value="0">Style ?</option>
<option value="#">-------</option>
<option value="http://your-domain/index.php?t=Nr.1">Style 1</option>
<option value="http://your-domain/index.php?t=Nr.2">Style 2</option>
</select>
</form>
You can put it for a test in templates/default/home.html under
{user_box}
But i dont now, it is work for Opera and Firefox...
cu
Kurt
-
Hallo,
bei dir wird anscheinend $t nicht übergeben..
Füge mal folgenden code in global.php ein
suche:
<?php
danach einfügen:
$t = (isset($HTTP_GET_VARS['t'])) ? intval(trim($HTTP_GET_VARS['t'])) : 0;
- Wenn das nicht klappt, das gleiche mal in index.php
- Wenn das nicht klappt:
install mal eine neue Galerie, kannst ja die gleiche db verwenden.
Hier nochmals testen, egal, ob die thumbs und bilder angezeigt werden...
- Wenn das nicht klappt, dann bin ich auch am Ende mit meiner Weisheit...
Kurt
-
Hi Kurt,
Auf Wunsch einiger User, hab ich das mal in meiner Testumgebung eingebaut
Hab leider auch das Problem, das keine Änderung eintrifft
dein Tipp
$t = (isset($HTTP_GET_VARS['t'])) ? intval(trim($HTTP_GET_VARS['t'])) : 0;
hab ich auch eingebaut, ebenfalls deinen Wechsler
http://ue-ei-portal-sammlerkatalog.de/katupdate
links unter den Kategorien Testhalber eingefügt, Style 1 sollte jetzt das default aufrufen
eigenartiger Weise kommt auch eine Fehlermeldung in der Sitemape
http://ue-ei-portal-sammlerkatalog.de/katupdate/sitemap_v2.php
Zeile 400 gehört zu der Modifikation
session_register("user_template");
hier mal die Änderung
//-----------------------------------------------------
//--- Generate Setting --------------------------------
//-----------------------------------------------------
$sql = "SELECT setting_name, setting_value
FROM ".SETTINGS_TABLE;
$result = $site_db->query($sql);
if (!$result) {
echo $lang['no_settings'];
exit;
}
while ($row = $site_db->fetch_array($result)) {
$config[$row['setting_name']] = $row['setting_value'];
}
// registering global variable "user_template"
if (!isset($user_template))
session_register("user_template");
// check global variable for Empty
if ($user_template=="" || empty($user_template))
$user_template = $config['template_dir'];
// set the Template if QueryString is not nothing
if (!empty($t) || $t != "")
$user_template = $t;
$config['template_dir'] = $user_template;
$site_db->free_result();
$config['allowed_mediatypes'] = str_replace(" ", "", $config['allowed_mediatypes']);
$config['allowed_mediatypes_array'] = explode(",", $config['allowed_mediatypes']);
$config['allowed_mediatypes_match'] = str_replace(",", "|", $config['allowed_mediatypes']);
$msg = "";
$clickstream = "";
define('MEDIA_PATH', ROOT_PATH.MEDIA_DIR);
define('THUMB_PATH', ROOT_PATH.THUMB_DIR);
define('MEDIA_TEMP_PATH', ROOT_PATH.MEDIA_TEMP_DIR);
define('THUMB_TEMP_PATH', ROOT_PATH.THUMB_TEMP_DIR);
define('TEMPLATE_PATH', ROOT_PATH.TEMPLATE_DIR."/".$config['template_dir']);
define('ICON_PATH', ROOT_PATH.TEMPLATE_DIR."/".$config['template_dir']."/icons");
vielleicht machst Du da mal einen schönen Mod für die 1.7.6 raus, so mit Box :wink:
LG. Harald
-
it seem like this mood doesn't work in 4images v 1.7.6 [ i try already ]
-
Ops sorry .. i'm wrong this mood can work only if register global is on ..in php
-
anyone know how to run this mood for register global when set to OFF
-
Replace
$t = (isset($HTTP_GET_VARS['t'])) ? intval(trim($HTTP_GET_VARS['t'])) : 0;
so
if (isset($HTTP_GET_VARS['t']) || isset($HTTP_POST_VARS['t'])) {
$t = (isset($HTTP_GET_VARS['t'])) ? stripslashes(trim($HTTP_GET_VARS['t'])) : stripslashes(trim($HTTP_POST_VARS['t']));
} else $t = "";