Removing content with Themes? Removing content with Themes?
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Removing content with Themes?

Started by zharling, February 01, 2005, 03:16:25 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

zharling

I have a site for my kid that uses iframes and I wanted to link in coppermine, problem is I need to slim it way down.  I can remove the head stuff with themes but can not seam to remove the content (ie random images and newly added images)  I know I can do this via config but the goal was to have one theme for my kids site then another for the rest of the pictures I wanted to put into coppermine and use a theme that is not 'slimmed down'.

The only way I could think of doing it was to have two installes and two db's, I'd rather not do that if I don't have to.

Anyone have any suggestions?

donnoman

in your include/init.inc.php right BEFORE the final "?>" thats at the end of the page; insert this:

// override main_page_layout for a specific theme
$CONFIG['main_page_layout'] = ($CONFIG['theme'] == 'water_drop') ? 'breadcrumb/alblist/catlist' : $CONFIG['main_page_layout'];
// override main_page_layout for a specific theme


This does it for the theme "water_drop"; of course you would substitute your own theme for that parameter.

Good luck.

zharling

Damm... That is perfect!!! Thanks!!


Ok heres another one, hopefully its just as easy for you.

My kids site would iframe to .../index.php?theme=theme

But most ppl would just go to ../index.php and use whatever the default theme is, which WILL be diffrent that my kids site.

The problem is if I access my kids site using his theme then go back to my main album its using his theme, and visa verca.

Hopefully this makes sense and you have another good idea.

Thanks,

zharling

Also forgot to ask above, is it documented anywhere what each config var is?

Like you said $CONFIG['main_page_layout'] was for "The content of the main page" 

I assume them to all have var names are they listed out anyplace?

donnoman

Easy question first: How to find what config variables there are:

lang/english.php; find:

if (defined('CONFIG_PHP')) $lang_config_data = array(


Look at the items in the array: The first field is what it's used for; the second is what the index is for that variable.

Now for tricking coppermine to hand out a different cookie name for a specific theme:
(FYI, this is probably not a wise thing to do if you use Coppermine bridged to anything)

include/init.inc.php; find:

// Process theme selection if present in URI or in user profile
if (!empty($HTTP_GET_VARS['theme'])) {
   $USER['theme'] = $HTTP_GET_VARS['theme'];
}
// Load theme file
if (isset($USER['theme']) && !strstr($USER['theme'], '/') && is_dir('themes/' . $USER['theme'])) {
   $CONFIG['theme'] = strtr($USER['theme'], '$/\\:*?"\'<>|`', '____________');
} else {
   unset($USER['theme']);
}
if (!file_exists("themes/{$CONFIG['theme']}/theme.php")) $CONFIG['theme'] = 'classic';
require "themes/{$CONFIG['theme']}/theme.php";
$THEME_DIR = "themes/{$CONFIG['theme']}/";


change to:

// moved theme block to just under the include of media.functions.inc.php for cookie_name mod



include/init.inc.php; find:  

require 'include/media.functions.inc.php';


add after it:

// moved block so that the theme would be set prior to substituting the cookie_name
// Process theme selection if present in URI or in user profile
if (!empty($HTTP_GET_VARS['theme'])) {
   $USER['theme'] = $HTTP_GET_VARS['theme'];
}

// check referrer for our target theme; needed if a cookie has not been saved yet
// otherwise you will get the login screen from the theme from the regular cookie
// and it will not let you log on.
$USER['theme'] = (strpos($REFERER,'water_drop')) ? 'water_drop' : $USER['theme'];

// Load theme file
if (isset($USER['theme']) && !strstr($USER['theme'], '/') && is_dir('themes/' . $USER['theme'])) {
   $CONFIG['theme'] = strtr($USER['theme'], '$/\\:*?"\'<>|`', '____________');
} else {
   unset($USER['theme']);
}
if (!file_exists("themes/{$CONFIG['theme']}/theme.php")) $CONFIG['theme'] = 'classic';
require "themes/{$CONFIG['theme']}/theme.php";
$THEME_DIR = "themes/{$CONFIG['theme']}/";
// moved block so that the theme would be set prior to substituting the cookie_name

// override cookie_name for a specific theme
$CONFIG['cookie_name'] = ($CONFIG['theme'] == 'water_drop') ? 'cpg_water_drop' : $CONFIG['cookie_name'];
// override cookie_name for a specific theme


Hope that helps;

FYI, the two mod questions were pretty well related, so they were good to have in the same thread. In the future if you have a slightly off topic question it's better to create a new thread, that way its easier for others to search and find relevant answers based on the TITLE of the thread, rather than having to open and search each one.

zharling

#5
thanks for the response.  When I move that code and add that bit I get

Undefined variable: USER

do I need to Dim that var or something?


This is the line that is erroring out on
$USER['theme'] = (strpos($REFERER,'water_drop')) ? 'water_drop' : $USER['theme'];

donnoman

that block should really come after the call to user_get_profile; but since we need to change the cookie before we get to that function; we have to mess with things a little bit.

find:

require 'include/media.functions.inc.php';


add after it:

$USER=array();


and the warning coming up in notices should go away.

zharling

I added the code and its continues to come up, didn't seam to change anything/

if it helps here is the my URL

www.zdsys.com/album       <-- This is my main pic site
www.zdsys.com/jacob1/pics_new.html   <-- this is too my kids site that iframs into http://www.zdsys.com/album/index.php?theme=ZDSYS

donnoman

move this block:

// check referrer for our target theme; needed if a cookie has not been saved yet
// otherwise you will get the login screen from the theme from the regular cookie
// and it will not let you log on.
$USER['theme'] = (strpos($REFERER,'water_drop')) ? 'water_drop' : $USER['theme'];


to just above this block:

// override cookie_name for a specific theme
$CONFIG['cookie_name'] = ($CONFIG['theme'] == 'water_drop') ? 'cpg_water_drop' : $CONFIG['cookie_name'];
// override cookie_name for a specific theme


The other thing to keep in mind is it's fine to have debug mode on when your working on mods like this,
but you should disable notices in debug, or at least restrict them to the admin when you go production.

My install isn't getting those errors even without moving the above block. I would review the changes you've made,
if you still can't nail it down, zip up your file and attach it to your post, and I'll take a look at it.

Also note that WATER_DROP != water_drop != Water_Drop

I didn't take any care to write the code to be tolerant of CASE. It simply looks
for string equivalence, if you have one character off, it's not going to work right.

ie: don't pass "theme=Water_Drop" if you modded it as "water_drop".

zharling

#9
Still getting the same message.

I have tried to upload the content but for some reason its not working so I put it out on the web server you can download the zip from this url

[edit]link to file removed[/edit]
Again thanks for all of your help on this.

donnoman

The more I dig into this the more I come back with this is a no-can-do item.

You can override the cookie name when the page is passed with theme=ZDSYS, and even check the referrer links.

But many pages, like the alb catlist and thumbnails don't pass this information, so we've got no clues that we should change the cookie name. so the system reads the deafult cookie and switches the theme to whatever is in the default cookie name.

you can clean up your overrides for the ZDSYS theme as follows:
at the bottom of init.inc.php

// override settings for a specific theme
if (stristr($CONFIG['theme'],'ZDSYS')) {
    $CONFIG['main_page_layout'] = 'breadcrumb/alblist/catlist';
    $CONFIG['picture_width'] = '400';
}


I'm not finding an easy way to redirect the theme when you visit the site later without the iframe.

I would suggest a few possible routes to try and get what you want.

1) Just code a theme that matches Jacob's site and get rid of the iframe. At least you would be able to switch themes at that point.

2) Look at the mod coppermine fetch in the forums, perhaps if you use that and just pull the Jacob images out you might get something that will satisfy your needs.

3) If you want to try to bark up the change the cookie method, the only way I figure you would be able to get it to work is going through A LOT of coppermine code putting conditionals in such that if theme=zdsys then tack on &theme=zdsys to the href.  There's a lot of code that would need to be gone through to make it work. (That's why I suggest abandoning the idea of messing with the cookie name)

4) Make two galleries with different cookie_names.

zharling

I can not thank you enough for the time you have spent investigating my request.

I think what I decided to do is to do a second install (two galleries) and write a script to go through and basically select out all new images out of the tbl in Jacob's and insert them into the main album. Then just keep two copies of the picutres on the server.


Should work.

Again thanks alot for all of your help.