Author Topic: Template Selector  (Read 18737 times)

0 Members and 1 Guest are viewing this topic.

Offline anicol

  • Newbie
  • *
  • Posts: 18
    • View Profile
Template Selector
« on: September 27, 2007, 05:11:30 PM »
I want the user to be able to select what template they can see

I tried the following link _> http://www.4homepages.de/forum/index.php?topic=1281.msg30839#msg30839

4th post down ->     
visitors to 4images pick template.
« Reply #3 on: August 05, 2002, 11:28:41 AM »

I see the drop down from the templates but when I select one it just refreshes the screen and does not load it
The address does change though example
http://domain/4images/index.php
to
http://domain/4images/index.php?&t=4bare

Any ideas?

Offline KurtW

  • 4images Guru
  • *******
  • Posts: 2.778
    • View Profile
    • Malediven-Bilder ~~Dreams~~
Re: Template Selector
« Reply #1 on: September 27, 2007, 05:25:57 PM »
Hi

first use this link:
http://domain/4images/index.php?t=4bare

Kurt

Offline anicol

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Template Selector
« Reply #2 on: September 27, 2007, 05:31:40 PM »
Does not load correct template but if I seleted 4bare as my default in general settings it works


Any idea's?
« Last Edit: September 27, 2007, 07:02:33 PM by anicol »

Offline KurtW

  • 4images Guru
  • *******
  • Posts: 2.778
    • View Profile
    • Malediven-Bilder ~~Dreams~~
Re: Template Selector
« Reply #3 on: September 27, 2007, 07:41:59 PM »
link?

Offline anicol

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Template Selector
« Reply #4 on: September 27, 2007, 07:45:56 PM »
I don't really want to post the link on the form for privite reasons so I PM'ed you

Offline KurtW

  • 4images Guru
  • *******
  • Posts: 2.778
    • View Profile
    • Malediven-Bilder ~~Dreams~~
Re: Template Selector
« Reply #5 on: September 27, 2007, 07:51:59 PM »
Change your code:
Code: [Select]
<select name="select_template" onChange="javascript:if(options[selectedIndex].value!='0') document.location.href=options[selectedIndex].value; ">
<option value="0">Select a Template</option>
<option value="/4images/index.php?&t=4bare&t=default&t=4bare">4bare</option>
<option value="/4images/index.php?&t=4bare&t=default&t=default">default</option>
</select>

to:

Code: [Select]
<select name="select_template" onChange="javascript:if(options[selectedIndex].value!='0') document.location.href=options[selectedIndex].value; ">
<option value="0">Select a Template</option>
<option value="index.php?t=4bare">4bare</option>
<option value="index.php?t=default">default</option>
</select>

But you can find this code also in my last post in the mod thread............
Also wrong:  your language dropdown  :!:




########################### EDIT ##########################

But you make anything wrong in global.php    .... the stylechange is not working

Kurt

Offline anicol

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Template Selector
« Reply #6 on: September 27, 2007, 08:02:06 PM »
maybe I did not follow the instructions on that post where I got the code from correctly

this is my header in the template


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="{direction}">
<head>
<title>{site_name}</title>
<meta http-equiv="content-type" content="text/html; charset={charset}" />
<link rel="stylesheet" href="{template_url}/style.css" />
<script language="javascript" type="text/javascript">
<!--

  var captcha_reload_count = 0;
   var captcha_image_url = "{url_captcha_image}";
  function new_captcha_image() {
    if (captcha_image_url.indexOf('?') == -1) {
        document.getElementById('captcha_image').src= captcha_image_url+'?c='+captcha_reload_count;
      } else {
        document.getElementById('captcha_image').src= captcha_image_url+'&c='+captcha_reload_count;
      }

    document.getElementById('captcha_input').value="";
    document.getElementById('captcha_input').focus();
    captcha_reload_count++;
  }

   function opendetailwindow() {
    window.open('','detailwindow','toolbar=no,scrollbars=yes,resizable=no,width=680,height=480');
  }
 
  function right(e) {
    if ((document.layers || (document.getElementById && !document.all)) && (e.which == 2 || e.which == 3)) {
      alert("© Copyright by {site_name}");
      return false;
    }
    else if (event.button == 2 || event.button == 3) {
      alert("© Copyright by {site_name}");
      return false;
    }
    return true;
  }

  if (document.layers){
    document.captureEvents(Event.MOUSEDOWN);
    document.onmousedown = right;
  }
  else if (document.all && !document.getElementById){
    document.onmousedown = right;
  }

   document.oncontextmenu = new Function("alert('© Copyright by {site_name}');return false");

// -->
</script>
{if has_rss}
<link rel="alternate" type="application/rss+xml" title="{rss_title}" href="{rss_url}" />
{endif has_rss}
</head>
<body bgcolor="#FFFFFF" text="#0F5475" link="#0F5475" vlink="#0F5475" alink="#0F5475">
<br />
<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>

Offline KurtW

  • 4images Guru
  • *******
  • Posts: 2.778
    • View Profile
    • Malediven-Bilder ~~Dreams~~
Re: Template Selector
« Reply #7 on: September 27, 2007, 08:04:54 PM »
the dynamic or the static code => not working
wrong global.php

Offline anicol

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Template Selector
« Reply #8 on: September 27, 2007, 08:09:14 PM »
the code I posted above is from the header.php for default template

I did put the other code in the global.php

Offline KurtW

  • 4images Guru
  • *******
  • Posts: 2.778
    • View Profile
    • Malediven-Bilder ~~Dreams~~
Re: Template Selector
« Reply #9 on: September 27, 2007, 08:14:53 PM »
1: you need the mod code in global.php
2: you need this code in header.html (in every template folder):
Code: [Select]
<select name="select_template" onChange="javascript:if(options[selectedIndex].value!='0') document.location.href=options[selectedIndex].value; ">
<option value="0">Select a Template</option>
<option value="index.php?t=4bare">4bare</option>
<option value="index.php?t=default">default</option>
</select>


Finish

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Template Selector
« Reply #10 on: September 27, 2007, 08:15:44 PM »
Replace:

Quote
<select name="select_template" onChange="javascript:if(options[selectedIndex].value!='0') document.location.href=options[selectedIndex].value; ">
<option value="0">Select a Template</option>
<option value="index.php?t=4bare">4bare</option>
<option value="index.php?t=default">default</option>
</select>

for:

Code: [Select]
<select name="select_template" onChange="javascript:if(options[selectedIndex].value!='0') document.location.href=options[selectedIndex].value; ">
<option value="0">Select a Template</option>
<option value="{self_full}?t=4bare">4bare</option>
<option value="{self_full}?t=default">default</option>
</select>
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline KurtW

  • 4images Guru
  • *******
  • Posts: 2.778
    • View Profile
    • Malediven-Bilder ~~Dreams~~
Re: Template Selector
« Reply #11 on: September 27, 2007, 08:18:29 PM »
the dropdown is not the problem, code from global.php is wrong


Kurt

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Template Selector
« Reply #12 on: September 27, 2007, 08:20:09 PM »
I make this replace because you use index.php with no $site_sess ... is no stable. Must use tags link in template for sessions. If use PHP in HTML, use $site_sess directly.
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline anicol

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Template Selector
« Reply #13 on: September 27, 2007, 08:28:14 PM »
Ok in both headers of header.html I put

Code: [Select]
<select name="select_template" onChange="javascript:if(options[selectedIndex].value!='0') document.location.href=options[selectedIndex].value; ">
<option value="0">Select a Template</option>
<option value="index.php?t=4bare">4bare</option>
<option value="index.php?t=default">default</option>
</select>

In the global.php I have

Code: [Select]
//-----------------------------------------------------
//--- 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();

try the link I pmed you, still same issue

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Template Selector
« Reply #14 on: September 27, 2007, 08:32:45 PM »
@anicol:

Please use patch for dropdown.

For this:

Quote

// 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();

You should set in page_header.php with $site_sess->set_session_var, $site_sess->get_session_var and $site_sess->drop_session_var .

See example here:

http://www.4homepages.de/forum/index.php?topic=7701.msg91787#msg91787

;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?