Welcome to Geeklog, Anonymous Monday, October 14 2024 @ 06:10 pm EDT

Geeklog Forums

Stories in the menu


Status: offline

daveshorts

Forum User
Newbie
Registered: 09/23/03
Posts: 7
Hi
I have done a hack of the menu plugin so that you can allow stories in a topic to appear as a submenu of that topic. This is very useful if you want to use geeklog to produce a website rather than a community page. (if you want an example look at www.chaosscience.org.uk click on the stories on the Events_CHaOS Tour_2002 (or 2003) submenu). This also includes a couple of other menu related hacks.

I am not sure if I have done the altering of the topic interface correctly, but it works.

This is quite involved, and I think I have remembered everything I changed..

Here there are actually 3 Hacks

1. A little hack to article.php to stop the submenus collapsing when you select a story in a subtopic

2. A hack to add a flag to gl_topic called show_subtopic_stories, which will affect whether all the subtopic stories are listed in a topic

3. A hack to show stories in the menu

2&3 are a bit intertwined as they both involve altering the topic interface (is there a better way of doing this than just hacking the files?)


1. I have added a little hack at the beginning of article.php which means that when you click on a story the submenu doesn't collapse

Text Formatted Code
79,84d78
< //+++++++++++++++++++++++++++++++
< //     menu hack to stop menus collapsing on stories
<
<       $menu=$A['tid'];
< //++++++++++++++++++



 



2&3. you will have to add a couple of columns to gl_topics with mysql or something similar eg:


Text Formatted Code
alter table gl_topics add column show_stories tinyint(1) unsigned;
alter table gl_topics add column show_subtopic_stories tinyint(1) unsigned;



 


3. In functions.inc in /plugins/menu here is a new function called MNU_showstories which is called in MNU_showTopics


Text Formatted Code


329a330,357
>
> /**
> * lists all Available Stories for a topic as links
> *
> * Show the stories in a topic and prints them in HTML
> *
> */
>
> function MNU_showStories($tid,$show_stories,$indent){
>     global $_TABLES,$_CONF;
>     if($show_stories==1){
>       $result = DB_query("SELECT * FROM ".$_TABLES['stories']." WHERE tid='$tid' AND ". MNU_getPerms() ." AND draft_flag=0 ORDER BY date");
>
>
>         $nrows = DB_numRows($result);
>       for($i=0;$i<$nrows;$i++){
>           $A = DB_fetchArray($result);
>           $retval.="<a href='". $_CONF['site_url'] . "/article.php?story=" . $A['sid'] . "'>$indent" . $A['title'] . "</a><br>n";
>       }
>     return $retval;
>
>     }
>     else{
>         return '';
>     }
> }
>
>
344d371
<
353d379
<
392c418,419
<                     if ((($lflg == 1) && ($menua[$lsz-1] != $labela[$lsz-1])) || ($CONFIG_MENU['showmonths'] == 1)){ $cnt .= ' ' . $CONFIG_MENU['chevron']; }
---
>                     if ((($lflg == 1) && ($menua[$lsz-1] != $labela[$lsz-1])) || ($CONFIG_MENU['showmonths'] == 1)){ $cnt .= ' ' . $CONFIG_MENU['chevron']; $stories='';}
>                   else{$stories=MNU_showStories($A['tid'],$A['show_stories'],$tmp.$CONFIG_MENU['indent']);}
394c421
<                     $retval .= $T->parse( 'item', 'option' );
---
>                     $retval .= $T->parse( 'item', 'option' ) . $stories;
804c831





 


2. I have hacked the new-index_1_3_8.php
which lets you specify whether you want the list of stories in a topic to include the stories in the subtopics or not.


Text Formatted Code
138c138,144
<     $sql .= " AND left(tid,length('$topic')) = '$topic' ";
---
> //++++++++++++++++  Hack to add a show_sub_stories option on topics
>     if( DB_getItem ($_TABLES['topics'], 'show_subtopic_stories', "tid='$topic'" ) == 1 ){
>       $sql .= " AND left(tid,length('$topic')) = '$topic' ";
>     }else{
>       $sql .= " AND tid = '$topic' ";
>     }
> //+++++++++++++++ end of dave hack




 




2&3. You want to add something like this to your {layout}/admin/topic/topiceditor.thtml so you can change the flags.

Text Formatted Code
                                        <td align="right">Show Stories in menu:</td>
                                        <td><input type="checkbox" size="48" maxlength="96" name="show_stories" value="1" {show_stories}></td>
                                    </tr>
                                    <tr>
                                        <td align="right">Show subtopic stories:</td>
                                        <td><input type="checkbox" size="48" maxlength="96" name="show_subtopic_stories" value="1" {show_subtopic_stories}></td>



 


2&3. You want to add something like this to the admin/topiceditor.php

I'm not sure this is the right way to do this as I have used HTTP_POST_VARS directly, which doesn't seem to be how it has been done before.

Text Formatted Code

112c112,117
<
---
>
>     if($A['show_stories']==1) {$show_stories_temp='checked';}else{$show_stories_temp='';}
>     $topic_templates->set_var('show_stories', $show_stories_temp);
>     if($A['show_subtopic_stories']==1) {$show_subtopic_stories_temp='checked';}else{$show_subtopic_stories_temp='';}
>     $topic_templates->set_var('show_subtopic_stories', $show_subtopic_stories_temp);
>
176,177c181,182
<     global $_TABLES, $_CONF, $LANG27, $MESSAGE;
<
---
>     global $_TABLES, $_CONF, $LANG27, $MESSAGE,$HTTP_POST_VARS;
185c190
<         $result = DB_query ("SELECT owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['topics']} WHERE tid = '{$tid}'");
---
>         $result = DB_query ("SELECT owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon,show_stories,show_subtopic_stories FROM {$_TABLES['topics']} WHERE tid = '{$tid}'");
217c222
<               DB_save($_TABLES['topics'],'tid, topic, imageurl, sortnum, limitnews, is_default, owner_id, group_id, perm_owner, perm_group, perm_members, perm_anon',"'$tid', '$topic', '$imageurl','$sortnum','$limitnews',$is_default,$owner_id,$group_id,$perm_owner,$perm_group,$perm_members,$perm_anon",$_CONF['site_admin_url'] . "/topic.php?msg=13");
---
>               DB_save($_TABLES['topics'],'tid, topic, imageurl, sortnum, limitnews, is_default, owner_id, group_id, perm_owner, perm_group, perm_members, perm_anon, show_stories, show_subtopic_stories',"'$tid', '$topic', '$imageurl','$sortnum','$limitnews',$is_default,$owner_id,$group_id,$perm_owner,$perm_group,$perm_members,$perm_anon,'".$HTTP_POST_VARS['show_stories']."','".$HTTP_POST_VARS['show_subtopic_stories']."'",$_CONF['site_admin_url'] . "/topic.php?msg=13");



 

 Quote

Status: offline

Blaine

Forum User
Moderator
Registered: 07/16/02
Posts: 1232
Location:Canada
Dave,

I think this is pretty neat and I also had to do a similar hack recently for a project. It was then that I realized a need for a plugin or a way that we can support this functionality without modifying core files.

A plugin would manage it using its own tables. I've used the sortorder field before to trigger a topic feature. Example a topic sortorder > 100 is used as a container for subitems or it should be hidden. But a new table to manage the structure and features would be offer more flexibility.

I see a need to be able to define menu or category headings and link menu items to stories, staticpages, or external pages.

Then have a way to view this as a directory tree and easily move items around, set access rights etc.
Geeklog components by PortalParts -- www.portalparts.com
 Quote

Status: offline

daveshorts

Forum User
Newbie
Registered: 09/23/03
Posts: 7
It would be quite easy to give this it's own tables and turn it into a patch to the menu plugin.
It is just nice having the extra options in the topiceditor from a usability point of view.

Is there any way of a plugin putting options for it's own tables in one of the standard geeklog dialogs?

On the longer term options:
I don't think you want to do everything with the menu, because you still need the concept of a subtopic*, as sometimes you want the front page of a topic to include all the stories from it's subtopics... and this wants to be, at least appear to the user, a property of the topic...

(* Or even better a super topic - eg the topic this new topic is in )

You also want the menu to update when you add stories/topics without going to the menu configurator (maybe I'm just lazy)

You could get round this if one of the objects you can put in your directory menu is a collection of topics/stories/pictures...
 Quote

Status: offline

Blaine

Forum User
Moderator
Registered: 07/16/02
Posts: 1232
Location:Canada
I agree with those features as well and want to look into this some more. I just need to get a couple projects finished before I get too excited about another one.

In the meantime, your documented hack should really help others.

Plugins could access other tables no problem. We just tend to want plugins and blocks to be self-sufficent. They can definitely alter other tables if they need and are extending or simulating other functions.
Geeklog components by PortalParts -- www.portalparts.com
 Quote

Status: offline

daveshorts

Forum User
Newbie
Registered: 09/23/03
Posts: 7
Cool, possibly the way to do it would be for the plugin to replace the topiceditor dialog, or does that require a hack anyway? I think subtopics require the hack to index.html that is already in the menu plugin anyway so it can't be entirely self sufficient.

While we are thinking about it allowing stories to be in more than one topic at the same time.., is related...


on a more unrealistic note ( I think I may have been thinking about this to long Wink )

Maybe you do want to do everything in the menu, in fact you could put everything (topics, stories, staticpages, forum posts etc ) in a big tree structure automatically, and a reference to the record itself. You then have a load of properties about whether each tree object can have sub-objects, and how they should display (on the menu, in a storylist, in a comment list etc)

This would probably make a static-page be just a story with a certain set of options set...

It would possibly also make searches of lots of different kinds of objects more elegent, and allow you to search everything in a topic, all the comments in a story, or all the forum posts in a thread...

You could also have hidden sections, like 'export to rdf file' which would would act as internal flags. and could be setup by plugins... And even appear as checkboxes on the user interface...

I think the hardest thing would be the user interface for a really big tree - as to do it properly would involve quite a lot of javascript and downloading the whole tree to the local machine, or maybe you could just download a certain number of layers and when you go any deeper it calls back to the server...

I have been playing with tree structures recently for my photo-album I've been writing, so I may have a play
 Quote

All times are EDT. The time is now 06:10 pm.

  • 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