Welcome to Geeklog, Anonymous Monday, January 13 2025 @ 12:17 am EST
Geeklog Forums
Theme by topic
Status: offline
jlhughes
Forum User
Full Member
Registered: 04/25/02
Posts: 154
I'm building a Web site that will be shared by several soccer teams.
Dividing the content between the teams is a piece of cake with Geeklog groups and topics.
What would be necessary in order to have a different theme load when you changed topics (or, in this case, teams)?
I'm looking to personalize each team's site as much as possible without a dozen separate Geeklog installs on one server.
John Hughes
3
3
Quote
Status: offline
rawdata
Forum User
Full Member
Registered: 02/17/03
Posts: 236
If you want a different theme for each topic page not just a different header and footer template as was done in the other hack then try this instead. Make a switch statement and assign a theme to each soccer team. The default should contain the theme you want for the rest of your site plus user chosen theme logic if you allow it. As written, this will override vistors' personal theme choices anytime they enter your team topics but reverts back to theirs or your default one when they go to another section of the site.
Example:
switch($topic) {
case 'team1': { $_CONF['theme'] = 'champions'; break; }
case 'team2': { $_CONF['theme'] = 'winsomelosesome'; break; }
case 'team3': { $_CONF['theme'] = 'alwaysdeadlast'; break; }
default: { $_CONF['theme'] = 'classic';
if( $_CONF['allow_user_themes'] == 1 ) {
if( isset( $HTTP_COOKIE_VARS[$_CONF['cookie_theme']]) && empty($_USER['theme'] )) {
if( is_dir( $_CONF['path_themes'] . $HTTP_COOKIE_VARS[$_CONF['cookie_theme']] )) {
$_USER['theme'] = $HTTP_COOKIE_VARS[$_CONF['cookie_theme']];
}
}
if( !empty( $_USER['theme'] )) {
if( is_dir( $_CONF['path_themes'] . $_USER['theme'] )) {
$_CONF['theme'] = $_USER['theme'];
$_CONF['path_layout'] = $_CONF['path_themes'] . $_CONF['theme'] . '/';
$_CONF['layout_url'] = $_CONF['site_url'] . '/layout/' . $_CONF['theme'];
}
else {
$_USER['theme'] = $_CONF['theme'];
}
}
}
break;
}
}
$_USER['theme'] = $_CONF['theme'];
$_CONF['path_layout'] = $_CONF['path_themes'] . $_CONF['theme'] . '/';
$_CONF['layout_url'] = $_CONF['site_url'] . '/layout/' . $_CONF['theme'];
Replace this section in lib-common.php with the above code:
if( $_CONF['allow_user_themes'] == 1 )
{
if( isset( $HTTP_COOKIE_VARS[$_CONF['cookie_theme']]) && empty($_USER['theme'] ))
{
if( is_dir( $_CONF['path_themes'] . $HTTP_COOKIE_VARS[$_CONF['cookie_theme']] ))
{
$_USER['theme'] = $HTTP_COOKIE_VARS[$_CONF['cookie_theme']];
}
}
if( !empty( $_USER['theme'] ))
{
if( is_dir( $_CONF['path_themes'] . $_USER['theme'] ))
{
$_CONF['theme'] = $_USER['theme'];
$_CONF['path_layout'] = $_CONF['path_themes'] . $_CONF['theme'] . '/';
$_CONF['layout_url'] = $_CONF['site_url'] . '/layout/' . $_CONF['theme'];
}
else
{
$_USER['theme'] = $_CONF['theme'];
}
}
}
That's it. This should allow you to set up a completely different theme for each topic.
Example:
Text Formatted Code
switch($topic) {
case 'team1': { $_CONF['theme'] = 'champions'; break; }
case 'team2': { $_CONF['theme'] = 'winsomelosesome'; break; }
case 'team3': { $_CONF['theme'] = 'alwaysdeadlast'; break; }
default: { $_CONF['theme'] = 'classic';
if( $_CONF['allow_user_themes'] == 1 ) {
if( isset( $HTTP_COOKIE_VARS[$_CONF['cookie_theme']]) && empty($_USER['theme'] )) {
if( is_dir( $_CONF['path_themes'] . $HTTP_COOKIE_VARS[$_CONF['cookie_theme']] )) {
$_USER['theme'] = $HTTP_COOKIE_VARS[$_CONF['cookie_theme']];
}
}
if( !empty( $_USER['theme'] )) {
if( is_dir( $_CONF['path_themes'] . $_USER['theme'] )) {
$_CONF['theme'] = $_USER['theme'];
$_CONF['path_layout'] = $_CONF['path_themes'] . $_CONF['theme'] . '/';
$_CONF['layout_url'] = $_CONF['site_url'] . '/layout/' . $_CONF['theme'];
}
else {
$_USER['theme'] = $_CONF['theme'];
}
}
}
break;
}
}
$_USER['theme'] = $_CONF['theme'];
$_CONF['path_layout'] = $_CONF['path_themes'] . $_CONF['theme'] . '/';
$_CONF['layout_url'] = $_CONF['site_url'] . '/layout/' . $_CONF['theme'];
Replace this section in lib-common.php with the above code:
Text Formatted Code
if( $_CONF['allow_user_themes'] == 1 )
{
if( isset( $HTTP_COOKIE_VARS[$_CONF['cookie_theme']]) && empty($_USER['theme'] ))
{
if( is_dir( $_CONF['path_themes'] . $HTTP_COOKIE_VARS[$_CONF['cookie_theme']] ))
{
$_USER['theme'] = $HTTP_COOKIE_VARS[$_CONF['cookie_theme']];
}
}
if( !empty( $_USER['theme'] ))
{
if( is_dir( $_CONF['path_themes'] . $_USER['theme'] ))
{
$_CONF['theme'] = $_USER['theme'];
$_CONF['path_layout'] = $_CONF['path_themes'] . $_CONF['theme'] . '/';
$_CONF['layout_url'] = $_CONF['site_url'] . '/layout/' . $_CONF['theme'];
}
else
{
$_USER['theme'] = $_CONF['theme'];
}
}
}
2
3
Quote
Status: offline
jlhughes
Forum User
Full Member
Registered: 04/25/02
Posts: 154
Applied the suggested hack to lib-common and, indeed, the topic theme displays when you click on the Section topic link.
However, when you click on "read more" on a story in the topic the theme reverts to the default.
Any ideas on how to keep the topic theme when reading an article in the topic?
You can see this at work by clicking on Hotspurs section here.
5
4
Quote
Status: offline
rawdata
Forum User
Full Member
Registered: 02/17/03
Posts: 236
Sorry, I didn't test the "read more" link. The topic is being lost when it goes into the article which is causing it to switch back. When someone goes straight to the article bypassing the front page they probably should see the right theme too. I'll play around with it some more and see if I can figure this out.
I forgot to mention last night in my previous post that you can name the themes the same as the topics (similar to what was done in the other hack) and use something like this instead of listing each team out.
case $topic: { $_CONF['theme'] = $topic; break; }
You can use an if else statement instead of a switch since there won't be as many conditions.
4
4
Quote
All times are EST. The time is now 12:17 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content