Welcome to Geeklog, Anonymous Wednesday, December 11 2024 @ 12:28 am EST

Geeklog Forums

Hack wanted: storytext.thtml

Page navigation


Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
I think I had had a good idea in this thread: http://www.geeklog.net/forum/viewtopic.php?forum=8&showtopic=79152

The idea to use different storytext.thtml files like topic1_storytext.thtml or topic2_storytext.thtml etc. to make the various topics look more differently.

Of course one could change the CSS with a topic or the whole theme but this is not always wanted or sufficient.

What about noting this in the functions.php ? There is already a similar procedure with

$_BLOCK_TEMPLATE['_staticpages_block'] = 'staticpcenterheader.thtml,staticpcenterfooter.thtml';


This feature would be good anyway especially if a site becomes bigger and you have some sort of subdirectories and you definitely want them to look different.
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
If you are running the latest version of my Caching Template Library, you can already do this with changes you put in your lib-custom.php. Not only that, but it would work for any and all templates, not just storytext.thtml.

The latest CTL has a feature where you can hook certain template functions. Set_root in the CTL can look in multiple directories for template files. So you hook set_root such that in addition to looking for templates in $_CONF['path_layout'] it should first look in $_CONF['path_layout']. $topic .'/'

So if layout/themename/topic1/storytext.thtml exists it is used otherwise the template class uses the normal layout/themename/storytext.thtml.

Details of the hack (solving a different problem) can be found in this post over on gllabs.org.
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
I haven't tested this but with the CTL in SVN over at gllabs.org, this code should do what you want:
Text Formatted Code
//Here's the code for lib-custom.php
if (isset($_REQUEST['topic']))
{
    $topic = COM_applyFilter($_REQUEST['topic']);
    $OldSetRootHook = $TEMPLATE_OPTIONS['hook']['set_root'];
    $TEMPLATE_OPTIONS['hook']['set_root'] = 'AddTopicToTemplates';
}

/* @param $root   array   The list of root directories passed to Template::set_root
 *  @return      array  The new list of root directories used by the Template
 */
function AddTopicToTemplates($root)
{
    global $topic, $OldSetRootHook;

    $A = array();
    $cleantopic = strtr($topic, ' \\/', '___'); // remove any path indicators from the topic
    foreach ($root as $path) {
        if (substr($path, -1) == '/') $A[] = $path . $cleantopic;
        else $A[] = $path . '/' . $cleantopic;
        $A[] = $path;
    }
    // maintain the chain of hooks, if necessary
    if ($OldSetRootHook)  return $OldSetRootHook($A);
    return $A;
}
 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
:shock: wooooooooow!

You see, that way one could modify the topics and e.g. make an FAQ or bug report, feature request topic. The bug_report_storytext.thtml could have several more fields than an ordinary storytext.thtml. Actually one doesn`t need many more but something like a status "being worked on by userXY" or so. To keep an overview there could be a static page on the top automatically listing the open or closed stories.

This way Geeklog could have its own mantis or whatever replacement instead of long waiting for anything difficult and external to be installed. I love small practical ideas and this is one.

Another idea would be that in a multiblog Geeklog every blogger could have his own layout, as dicussed in the thread mentioned above.

Great :banana:
 Quote

Status: offline

beewee

Forum User
Full Member
Registered: 08/05/03
Posts: 969
Location:The Netherlands, where else?
There's different and very easy approach, you can use the topic ID 'tid' to use separate classes:
Text Formatted Code
 <div class="{tid}">

Dutch Geeklog sites about camping/hiking:
www.kampeerzaken.nl | www.campersite.nl | www.caravans.nl | www.caravans.net
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
Reread his post, he said sometime just setting a new CSS class is not enough. You might want some topics to have certain story features in different locations
 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
O.k. that`s for the css only, is it? I did something where I changed the whole CSS in the header according to the topic.

I mentioned this in the other thread: "BTW here is an example of a changing header pic:"
http://www.montessori-schule-wertingen.de/public_html/index.php

But this is very often not enough and you don`t really want to change the whole theme.
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
With my hack, you aren't changing the whole theme. Just the files that you need to change are included in the topic directories. If it does not find the needed file in the topic subdirectory it looks in the normal directory for the file.

Or are you replying to beewee?
 Quote

Status: offline

beewee

Forum User
Full Member
Registered: 08/05/03
Posts: 969
Location:The Netherlands, where else?
I guess I missed this part Oops!

Of course one could change the CSS with a topic or the whole theme but this is not always wanted or sufficient.


I assumed too soon he ment the old Chameleon hack or the other mentioned CSS hack.
Dutch Geeklog sites about camping/hiking:
www.kampeerzaken.nl | www.campersite.nl | www.caravans.nl | www.caravans.net
 Quote

Status: offline

beewee

Forum User
Full Member
Registered: 08/05/03
Posts: 969
Location:The Netherlands, where else?
Quote by: 1000ideen

O.k. that`s for the css only, is it? I did something where I changed the whole CSS in the header according to the topic.

I mentioned this in the other thread: "BTW here is an example of a changing header pic:"
http://www.montessori-schule-wertingen.de/public_html/index.php



A bit off topic, Markus: what did you do with the hover class in the menubar? Looks different in IE7 and Firefox, and it seems it doesn't look like it's supposed to look.
Dutch Geeklog sites about camping/hiking:
www.kampeerzaken.nl | www.campersite.nl | www.caravans.nl | www.caravans.net
 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
Thank you both, there was a slight confusion in who is answering whom but anyway it is nice that you are trying to help. :shakehands:

Yes, I`ll give this cache a try, I think it is a good thing. I`d not have thought about using it because I don`t have a high traffic site yet. But it is nice trying out Joe`s inventions.

Actually I just installed the cache. It works fine even with 770 settings. I just don`t get one instruction

I found this line 190 in moderation.php:
$admin_templates->set_var('cc_icon_width', floor(100/ICONS_PER_ROW));

WHERE am I to cut and paste it?


So it will be part of GL core in 2010? Did anybody say there is no roadmap? :speechless:
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
Quote by: 1000ideen

Thank you both, there was a slight confusion in who is answering whom but anyway it is nice that you are trying to help. :shakehands:

Yes, I`ll give this cache a try, I think it is a good thing. I`d not have thought about using it because I don`t have a high traffic site yet. But it is nice trying out Joe`s inventions.

Well, the caching function I added is just one of many new features. MediaGallery will require the CTL with the next release because Mark is using those additional features beyond the caching features.

Actually I just installed the cache. It works fine even with 770 settings. I just don`t get one instruction

I found this line 190 in moderation.php:
$admin_templates->set_var('cc_icon_width', floor(100/ICONS_PER_ROW));

WHERE am I to cut and paste it?
It's been too long since I've installed it. The line you clipped is indeed the line that needs to move. Place it shortly after the $admin_templates variable is initialized and before the for () loop shortly after $admin_templates is initialized. I don't remember the line number.

The simpler solution is to use the zip file Mark made which contains modified versions of the 1.4.1 files you need. Additional instructions are here.

So it will be part of GL core in 2010? Did anybody say there is no roadmap? :speechless:

Don't be like that. That's my job. It's no fun be reviled. Trust me.

And that's not an official release date. Just my best guess. Smile
 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
The code you gave above starting with "//Here's the code for lib-custom.php" is to go into lib-custom.php ?

What am I to do next, how do I "hook set_root"?

Concerning the road map: http://www.geeklog.net/forum/viewtopic.php?showtopic=81135
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
Quote by: 1000ideen

The code you gave above starting with "//Here's the code for lib-custom.php" is to go into lib-custom.php ?

What am I to do next, how do I "hook set_root"?

That code does the hooking. You have to have the latest template_new.class.php file from SVN on gllabs.org. The download available here is an older version of the library.
 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
Sorry but I am not a programmer I only understand basic html and css. I pasted the above code into the lib-custom.php is this correct?

I downloaded this http://www.gllabs.org/filemgmt/index.php?id=156 correct?

Now, where do I tell the "thing" to use layout/themename/topic1/storytext.thtml Confused:
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
You don't need to do anything to hook it. The code you pasted does the hooking. Now you just need the right copy of the template library: It's still in the code repository not in the normal file download: file. You might need to do a save as... from your browser.
 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
O.k., I`m beginning to understand. Erm, does your cache remove php from the thtml? I have some php code in my thtml and it seems to be filtered out. Confused:
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
No, actually it should run no problem. In fact it should run in any thtml file now. Go to the cache (under data) directory and check that the php is or isn't in the cached file.
 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
I`m just about to send you an email with more details. It seems to cut out meta tags.

I cuts away this and this contains some php too:

Text Formatted Code
<meta name="language" content="de">
<meta name="robots" content="index follow">
<meta name="topic" lang="de" content=<?php print $_CONF['meta_tag_topic'];?>>
 Quote

Status: offline

samstone

Forum User
Full Member
Registered: 09/29/02
Posts: 820
Wow! Never realized that this Template Caching hack could do so many wonders with Geeklog.

A year ago, I tried to set up an English-Burmese website and was not successful because the Burmese fonts are not yet unicode standard and needed to be embedded; and I just couldn't mix the two with the same storytext.thtml. If I embed the Burmese fonts, the English articles looks ugly, and vise versa. So having separate CSS for the storytext.thtml of each topic would solve that problem.

I can't wait to try out this one.

BTW, each time I introduce myself as a Burmese, some people would ask me where Burma is. Now thanks to Sylvester Stallone for his latest Rambo movie so that I don't sound like an alien from another planet.
Big Grin
Thanks,

Sam
 Quote

Page navigation

All times are EST. The time is now 12:28 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