• [MOD] Members Templates Select 5 0 5 1
Currently:  

Author Topic: [MOD] Members Templates Select  (Read 83339 times)

0 Members and 1 Guest are viewing this topic.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[MOD] Members Templates Select
« on: June 12, 2003, 06:27:34 AM »
This is experemental MOD, that will let members select templates from list of avalable.
The reason it's "experemental" because some code from global.php has to move into /includes/sessions.php. With some tests I had on my site I didnt see any side effects though.

Another maybe usefull feature this mod will add into 4images is "dropdown" option in db_field_definitions.php


----- Changes in files --------

/global.php
/includes/sessions.php
/includes/functions.php
/includes/db_field_definitions.php
/member.php
/lang/<yourlanguage>/main.php
/admin/admin_functions.php
/templates/<yourtemplate>/member_editprofile.html


----- Installation ---------

Step 1.
Open /global.php
Find and delete (or comment):
Code: [Select]
define('TEMPLATE_PATH', ROOT_PATH.TEMPLATE_DIR."/".$config['template_dir']);
define('ICON_PATH', ROOT_PATH.TEMPLATE_DIR."/".$config['template_dir']."/icons");

Step 1.2
Find:
Code: [Select]
//-----------------------------------------------------
//--- Templates ---------------------------------------
//-----------------------------------------------------
include(ROOT_PATH.'includes/template.php');
$site_template = new Template(TEMPLATE_PATH);
Replace with:
Code: [Select]
//-----------------------------------------------------
//--- Templates ---------------------------------------
//-----------------------------------------------------
$dir = opendir(ROOT_PATH.TEMPLATE_DIR);
$templates_cache = array();
while($dir_cache = readdir($dir))
{
  if (@is_dir(ROOT_PATH.TEMPLATE_DIR."/".$dir_cache) && $dir_cache != "." && $dir_cache != "..")
  {
    $templates_cache[] = $dir_cache;
  }
}
closedir($dir);

Step 2.
Open /includes/sessions.php
Find:
Code: [Select]
if (defined("GET_USER_ONLINE") && ($config['display_whosonline'] == 1 || $user_info['user_level'] == ADMIN)) {Add before:
Code: [Select]
//-----------------------------------------------------
//--- Templates ---------------------------------------
//-----------------------------------------------------
$user_info['user_template'] = (isset($HTTP_GET_VARS['user_template'])) ? $HTTP_GET_VARS['user_template'] : ((isset($HTTP_POST_VARS['user_template'])) ? $HTTP_POST_VARS['user_template'] : $user_info['user_template']);
$user_template = ($user_info['user_template']) ? ((in_array($user_info['user_template'], $templates_cache)) ? $user_info['user_template'] : $config['template_dir']) : $config['template_dir'];
define('TEMPLATE_PATH', ROOT_PATH.TEMPLATE_DIR."/".$user_template);
define('ICON_PATH', ROOT_PATH.TEMPLATE_DIR."/".$user_template."/icons");
include(ROOT_PATH.'includes/template.php');
$site_template = new Template(TEMPLATE_PATH);
//--- End Templates -----------------------------------


Step 3.
Open /includes/functions.php
Add at the end, just before closing ?>
Code: [Select]
//--- DB Field Dropdown ---
function get_db_fields_dropdown($key, $val, $value) {
  $dropdown = "<SELECT name=\"".$key."\" onkeypress=\"if(window.event.keyCode==13)this.form.submit();\" class=\"select\">";
$i = 0;
foreach ($val[3] as $item) {
  $what = ($val[4]) ? $item : $i;
$dropdown .= "<option value=\"".$what."\"".(($value == $what) ? " selected" : "").">".$item."</option>\n";
$i++;
}
$dropdown .= "</select>\n";
  return $dropdown;
}
//--- End DB Field Dropdown ---


Step 4.
Open /includes/db_field_definitions.php
Add at the end, just before closing ?>
Code: [Select]
$additional_user_fields['user_template'] = array($lang['user_template'], "dropdown", 0, $templates_cache, 1);

Step 5.
Open /members.php
v1.7 / v1.7.1[/color]
Find:
Code: [Select]
      else{
        $value = (isset($HTTP_POST_VARS[$key])) ? htmlspecialchars(trim($HTTP_POST_VARS[$key])) : $user_info[$key];
Replace with:
Code: [Select]
      elseif ($val[1] == "dropdown") {
        $value = (isset($HTTP_POST_VARS[$key])) ? $HTTP_POST_VARS[$key] : $user_info[$key];
      $additional_field_array[$key.'_dropdown'] = get_db_fields_dropdown($key, $val, $value);
      }else{
        $value = (isset($HTTP_POST_VARS[$key])) ? htmlspecialchars(trim($HTTP_POST_VARS[$key])) : $user_info[$key];

v1.7.2
Find:
Code: [Select]
      else {
        $value = (isset($HTTP_POST_VARS[$key])) ? format_text(trim($HTTP_POST_VARS[$key]), 2) : $user_info[$key];
Replace with:
Code: [Select]
      elseif ($val[1] == "dropdown") {
        $value = (isset($HTTP_POST_VARS[$key])) ? format_text(trim($HTTP_POST_VARS[$key]), 2) : $user_info[$key];
      $additional_field_array[$key.'_dropdown'] = get_db_fields_dropdown($key, $val, $value);
      }else{
        $value = (isset($HTTP_POST_VARS[$key])) ? format_text(trim($HTTP_POST_VARS[$key]), 2) : $user_info[$key];


Step 6.
Open /lang/<yourlanguage>/main.php
Add at the end, just before closing ?>
Code: [Select]
//--- User templates --------
$lang['user_template'] = "Select style";
//--- End User templates ----


Step 7.
Open /admin/admin_functions.php
Find:
Code: [Select]
      case "text":Add before:
Code: [Select]
  case "dropdown":
show_dropdown_row($val[0], $field_name, $value, $val[3], $val[4]);
break;

Step 7.2.
Add at the end, just before closing ?>
Code: [Select]
function show_dropdown_row($title, $name, $value = 0, $array = array(), $value_show = 0){
$i = 0;
echo "<tr width=\"50%\"class=\"".get_row_bg()."\" valign='top'>\n<td><p class=\"rowtitle\">".$title."</p></td>\n";
echo "<td width=\"50%\" valign=\"middle\">\n<SELECT name=\"".$name."\" onkeypress=\"if(window.event.keyCode==13){this.form.submit();}\"\">";
foreach ($array as $key) {
  $what = ($value_show) ? $key : $i;
echo "<option value=\"".$what."\"".(($value == $what) ? " selected" : "").">".$key."</option>\n";
$i++;
}
echo "</select>\n</td>\n</tr>\n";
}


Step 8.
Open /templates/<yourtemplate>/member_editprofile.html
Add this:
Code: [Select]
          <tr>
            <td class="row1"><b>{lang_user_template}:</b></td>
            <td class="row1">
              {user_template_dropdown}
            </td>
</tr>
*Repeat Step 8. for each template, or your members wont be able change templates if chose the one without that change.


Step 9.
Download this installer.
Unpack it and upload user_template_install.php file into 4images root dir.
Install it http://yoursite.com/4images/user_template_install.php


If u did everything correctly, in control panel (not ACP) u should see new dropdown.
The script automaticaly scans /templates/ folder and if it finds any folders, it add them as selection, so be carefull, make sure that each of your template sets has all needed templates.
« Last Edit: September 18, 2006, 08:12:50 AM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline TomYork

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: [MOD] Members Templates Select
« Reply #1 on: March 29, 2005, 03:48:22 AM »
with the more statistics for your visits (mod posted on this forum), this mod have an error on the line 13 of stats.php, so i can't install this mod...

if u can, review that please


thnks
* La prueba más clara de la sabiduría es una alegría continua...*

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Members Templates Select
« Reply #2 on: March 29, 2005, 03:56:31 AM »
with the more statistics for your visits (mod posted on this forum), this mod have an error on the line 13 of stats.php, so i can't install this mod...

if u can, review that please


thnks
what mod? where? and which mod have error? stats.php absolutely has nothing to do with this mod...why did u reply here? :?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline TomYork

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: [MOD] Members Templates Select
« Reply #3 on: March 29, 2005, 04:51:12 AM »
http://www.4homepages.de/forum/index.php?topic=3303.0

These mod I installed and when install this mod crash

with the more statistics for your visits (mod posted on this forum), this mod have an error on the line 13 of stats.php, so i can't install this mod...

if u can, review that please


thnks
what mod? where? and which mod have error? stats.php absolutely has nothing to do with this mod...why did u reply here? :?
* La prueba más clara de la sabiduría es una alegría continua...*

Offline TubeTopia

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • TubeTopia
Re: [MOD] Members Templates Select
« Reply #4 on: April 17, 2005, 04:12:48 AM »
V@no when you have some time could you have a look @ what ive done wrong here.

www.tubetopia.com

Installed etc great just the template switches back to previous when you move out of control panel.
LOL can no longer see the forest for the trees here.

Like your site will need 2 register. Any help would be great  :D
"Don't worry about the world coming to an end today. It's already tomorrow in Australia." Charles Schultz

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Members Templates Select
« Reply #5 on: April 17, 2005, 04:33:19 AM »
Installed etc great just the template switches back to previous when you move out of control panel.
I have only two possible explanations:
1) member.php was altered with some other code which is conflicts with this mod
2) your database wasnt updated (Step 9)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline TubeTopia

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • TubeTopia
Re: [MOD] Members Templates Select
« Reply #6 on: April 17, 2005, 05:02:11 AM »
Thanks V@no,  :)

Thinking it might be a conflict, restored database & updated again still didnt work.
Restore my  8O  eyesight & will have a look @ the member.php @ some other time.

 :( Damn wanted this 1 to work . aint that always the way.
"Don't worry about the world coming to an end today. It's already tomorrow in Australia." Charles Schultz

Offline gifwav

  • Newbie
  • *
  • Posts: 37
    • View Profile
    • http://www.funpics4u.com
Re: [MOD] Members Templates Select
« Reply #7 on: May 24, 2005, 10:32:16 AM »
Hello,

I'm using 4Images for a website for the local volleyball club.
I've deleted the loginform (no members).
I want to create a separate section for kids, with a different layout.
What I want is: A link called KIDS linking to another layout using a different template.
It's possible on V@no's gallery to change the layout of his gallery by clicking "right or Auto-hide" in his left menu.
Can somebody help me with this?

Jan

Offline graficalicus

  • Full Member
  • ***
  • Posts: 235
    • View Profile
Re: [MOD] Members Templates Select
« Reply #8 on: May 27, 2005, 03:33:20 AM »
this works pretty well - except for a single conflict with an old rss mod I installed - here's the error I get:
Code: [Select]
Fatal error: Call to a member function register_vars() on a non-object in /blah/blah/blah/rss.php on line 38

line 38 is here:
Code: [Select]
  $site_template->register_vars(array(

and the complete rss.php code is this (rather short):
Code: [Select]
<?
//*************************************************
 /* RSS Feed for 4images                          *
 * beta 0.1                                      *
 */

//------------ CONFIG ----------------------------

$num_new_images = 10;
/*
 u can uncomment this, if you want to use config variables from 4images config
 $num_new_images = $config['image_cells'];
*/

//because we have no session here, we have to hardcode this values
define('SCRIPT_URL', 'http://digiart.graficalicus.com'); //no trailing slash
define('LANGUAGE', 'en-us');

define('ROOT_PATH', './');

//----- END CONFIG--------------------------------------------

include(ROOT_PATH.'global.php');
$main_template = 'rss';



$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, c.cat_name
        FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id
        ORDER BY i.image_date DESC
        LIMIT $num_new_images";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
$format="Y-m-d\TH:i:s+00:00"; //the time format for rss date
while($image_row = $site_db->fetch_array($result)){
  $site_template->register_vars(array(
      "title" => $image_row["image_name"],  
      "description" => $image_row["image_description"],
      "category_domain" => SCRIPT_URL."/categories.php?cat_id=".$image_row["cat_id"],
      "category" => $image_row["cat_name"],
      "link" => SCRIPT_URL."/details.php?image_id=".$image_row["image_id"],
      "date" => format_date($format,$image_row["image_date"]),
      ));
  $new_images.=$site_template->parse_template("rssitem");
 }

//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(
      array(
    "ctitle" => $config['site_name'],
    "clink" => SCRIPT_URL,
    "cdescription" => $config['site_name']." Last 5 images",
    "language" =>LANGUAGE,
    "ititle" =>"digiart galleries at the graficalicus workshop",    
    "iurl" => SCRIPT_URL."/digiart-graf_banner.gif",
    "ilink" => SCRIPT_URL,
    "items" => $new_images,  
    )
      );
header("Content-type: text/xml");
$site_template->print_template($site_template->parse_template($main_template));
?>

when the references to site template are removed, the rss feed can't figure out what rss template to use - - how can I tell it where to look for it?

thx - -

Offline gifwav

  • Newbie
  • *
  • Posts: 37
    • View Profile
    • http://www.funpics4u.com
Re: [MOD] Members Templates Select
« Reply #9 on: May 27, 2005, 05:42:00 PM »
Hello graficalicus,

Is this a reply to my question?
I don't understand.

Jan

Offline graficalicus

  • Full Member
  • ***
  • Posts: 235
    • View Profile
Re: [MOD] Members Templates Select
« Reply #10 on: May 27, 2005, 06:06:23 PM »
no, mine's a new question - - how to get the RSS mod know where to find the correct template after installing this one - -

you should try this MOD instead - I'm also using it for different category templates, and it works well -

http://www.4homepages.de/forum/index.php?topic=1847.0

be sure to read all the way through the posts - like I said, I have it working on my site just fine  8)

Offline graficalicus

  • Full Member
  • ***
  • Posts: 235
    • View Profile
Re: [MOD] Members Templates Select
« Reply #11 on: May 31, 2005, 04:19:41 AM »
<bump>

Quote
because some code from global.php has to move into /includes/sessions.php

this messes up this RSS MOD - and I apologise, but I can't recall the original author and the thread hasn't been recovered from a cache  :(

any ideas how to get that template info back into this rdd feed?  thanks - -   :wink:

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Members Templates Select
« Reply #12 on: May 31, 2005, 06:04:31 AM »
sorry, without knowing the installation instrutions of rss mod, noone can help u.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline graficalicus

  • Full Member
  • ***
  • Posts: 235
    • View Profile
Re: [MOD] Members Templates Select
« Reply #13 on: June 04, 2005, 07:35:28 PM »
Ahh - thanks, Chris - you found the rss mod I'm using!

http://www.4homepages.de/forum/index.php?topic=8240.0

So can anyone help with "hard-coding" this RSS  to a special category template?   Thanks!

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Members Templates Select
« Reply #14 on: June 04, 2005, 09:13:48 PM »
ok now, I see why its messing up RSS mod.

Simply insert in rss.php below
Code: [Select]
include(ROOT_PATH.'global.php');this:
Code: [Select]
include(ROOT_PATH.'includes/sessions.php');
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)