arbitrary starting level for NAV_TABLE_COLUMN

Use GitHub to post feature requests for phpwcms.
User avatar
Oliver Georgi
Site Admin
Posts: 9667
Joined: Fri 3. Oct 2003, 22:22
Location: Moscow, Russia
Contact:

arbitrary starting level for NAV_TABLE_COLUMN

Post by Oliver Georgi »

[UPDATE] Do not change anything - it is included since some months.

Hi,
no patch today - only for testing to anybody who wants to test this:

I extend the NAV_TABLE_COLUMN function to handle different level starting points.

What is it doing:
{NAV_TABLE_COLUMN} = system replaces with {NAV_TABLE_COLUMN:0} what means start at Top Level.

But now you can take any CAT-ID (in admin site structure) to start navigation at that given level. {NAV_TABLE_COLUMN:3}

change function nav_table_struct() in front.func.inc.php:

Code: Select all

function nav_table_struct ($struct, $act_cat_id, $level, $nav_table_struct, $link_to="index.php") {
	// start with home directory for the listing = top nav structure
	// 1. Build the recursive tree for given actual article category ID
	
	// return the tree starting with given start_id (like breadcrumb)
	// if the $start_id = 0 then this stops because 0 = top level
	
	$start_id = $act_cat_id;
	
	while ($start_id) {
		$data[$start_id] = 1;
		$start_id		 = $struct[$start_id]["acat_struct"];
	}
	$temp_tree = (sizeof($data)) ? array_reverse($data, 1) : false;
	
	foreach($struct as $key => $value) {
		if($struct[$key]["acat_struct"] == $act_cat_id && $key && !$struct[$key]["acat_hidden"]) $c++;
	}
	$c = (!$c) ? 1 : 0;
	
	//get depth of level
	$level_depth = 0; $start_level = $level;
	while ($start_level) {
		$start_level = $struct[$start_level]["acat_struct"];
		$level_depth++;
	}

	$temp_menu = build_levels ($struct, $level, $temp_tree, $act_cat_id, $nav_table_struct, $level_depth, $c, $link_to); //starts at root level
	return ($temp_menu) ? ("<table".table_attributes($nav_table_struct, "table", 0).">\n".$temp_menu."</table>") : "";
}
and in content.func.inc.php:

Code: Select all

// Left table based rollover navigation
if( ! ( strpos($content["all"],'{NAV_TABLE_COLUMN')===false ) ) {
	$content["all"] = str_replace('{NAV_TABLE_COLUMN}', '{NAV_TABLE_COLUMN:0}', $content["all"]); //content
	$replace = 'nav_table_struct($content["struct"],intval($content["cat_id"]),intval($1),$template_default["nav_table_struct"]);';
	$content["all"] = preg_replace('/\{NAV_TABLE_COLUMN:(\d+)\}/e', $replace, $content["all"]);
}
With that function I build a phpwcms installation with 4 different languages - every language has own identical tree strcuture - but different templates where I have setup the correct level start. To jump to the right page I use redirect pages.

Have fun. It runs stable.

Oliver
Last edited by Oliver Georgi on Mon 3. May 2004, 10:52, edited 2 times in total.
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон

marco

Post by marco »

This is great, it works just fine!

Note: It seems you can easily get the structure id by hovering the pointer above the article edit icon in the article center. At least that's what I do, since I am not sure if the id's stay the same and sequential if I move the categories around or insert new ones.

I think this can allow us to also have menus specific to the site area the user is visiting. For instance, we might create a top level site navigation menu like:

Home News Blog Columns Gallery Projects Forum

Then, each of these main site content areas can have their own menus, e.g.

Gallery
--People
--Travel
--Landscape
etc.

User avatar
Oliver Georgi
Site Admin
Posts: 9667
Joined: Fri 3. Oct 2003, 22:22
Location: Moscow, Russia
Contact:

Post by Oliver Georgi »

Yes that's what I forgot to tell you. Every little page or article icon has an ALT/TITLE info for you with its ID and for cat additional the alias (if one is defined).

IDs stays the same ever - also if you move or sort the category or the article.

Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон

hidiho
Posts: 38
Joined: Wed 3. Dec 2003, 23:44

Post by hidiho »

Great 'patch'- works ok

But... Breadcrumb won't start at the {NAV_TABLE_COLUMN:123} number level and therefore some weird results are shown.

My site structure
-index
- english (and below that all sublevels - like: about us/services/etc etc)
- dutch (below all sublevels - the same)

I use {BREADCRUMB} in my templates, somewhere in the header

It doesn't say: Home > English Level 1 > English sublevel1.1
but:
Home > English > English Level 1 > English Sublevel 1.1

So I thought; maybe {BREADCRUMB:NUMBER} would help in order to make it see "english" or "dutch" as the default starting point, thus "Home".

greetz
:shock:

User avatar
Oliver Georgi
Site Admin
Posts: 9667
Joined: Fri 3. Oct 2003, 22:22
Location: Moscow, Russia
Contact:

Post by Oliver Georgi »

OK - I think about that.
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон

jack
Posts: 2
Joined: Wed 17. Dec 2003, 22:25

Can't get me head around navigation strting points

Post by jack »

Hi I have implemented the code on

http://www.phpwcms.de/forum/viewtopic.php?t=287

but I am struggling to calculate the correct URL.

Could you please expalin how to set it up in very simple terms (as you may have guessed, I am not a programmer!)

Thanks - Jack

I have now worked this one out for myself - for any other newbies, with the default templates, you need to change the {NAV_TABLE_COLUMN} entry in "left" section of the template to cat number which you pick up in the site structure section, eg to {NAV_TABLE_COLUMN:3}.

User avatar
Oliver Georgi
Site Admin
Posts: 9667
Joined: Fri 3. Oct 2003, 22:22
Location: Moscow, Russia
Contact:

Post by Oliver Georgi »

Check article/structure listing - move your mouse pointer over the small page icon and a small tooltip will show structure ID
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон

waggis
Posts: 18
Joined: Wed 31. Dec 2003, 13:59

Post by waggis »

Hi,

I have just implemented the multilanguage functionality on my site. Works great. Only one little bug still remaining: the link article function does no more work correctly.

I have at this time 3 languages in use: french, german and english. A link within a german article to another german article shows the correct content but the wrong navigation (the one defined as default, in my case the french one).

A workaround is still possible: linking to the article using standard html code:

---------
<img alt="" hspace="0" src="img/article/intlink_1.gif" align="baseline" border="0" /><a href="url">text</a>
---------

You can have a look at http://www.exenta.com/site/index.php?de or http://www.exenta.com/site/index.php?en to see how it works.

phpwcms is a great thing, really. I've been searching for a non news based CMS for a long time and it's really the best I found.

Thanks to Oliver and all people involved in phpwcms.

Waggis

frold
Posts: 2151
Joined: Tue 25. Nov 2003, 22:42

Post by frold »

when it is done I hope you will share the code with us all :lol:
http://www.studmed.dk Portal for doctors and medical students in Denmark

User avatar
Oliver Georgi
Site Admin
Posts: 9667
Joined: Fri 3. Oct 2003, 22:22
Location: Moscow, Russia
Contact:

Post by Oliver Georgi »

I have made the small patch that article links will work well. The problem was that I forget to send the category ID too - so everytime cat ID 0 was loaded. Now it is set correct.

Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон

waggis
Posts: 18
Joined: Wed 31. Dec 2003, 13:59

Post by waggis »

Hi Oliver,

Tx for the fast reply. Where can I find this patch ? or the modified code ?

waggis

User avatar
Oliver Georgi
Site Admin
Posts: 9667
Joined: Fri 3. Oct 2003, 22:22
Location: Moscow, Russia
Contact:

Post by Oliver Georgi »

It's the first post of this thread.

But I will release a new version (today - I hope).
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон

waggis
Posts: 18
Joined: Wed 31. Dec 2003, 13:59

Post by waggis »

Thanks a lot. And a happy new year. do not work too hard :-)

waggis

User avatar
Pappnase
Posts: 6845
Joined: Thu 30. Oct 2003, 23:48
Location: Berlin, Germany

Post by Pappnase »

hello oliver

if you would have the version tomorrow ready it would be a great birthday present! :D
Pappnase
Last edited by Pappnase on Wed 31. Dec 2003, 16:49, edited 1 time in total.

marco

Post by marco »

waggis wrote:Hi,

I have just implemented the multilanguage functionality on my site. Works great. Only one little bug still remaining: the link article function does no more work correctly.

Waggis
Nice site!

But why is the entire page refreshing when navigating the menu items? It should only refresh the content and the menu. The header and footer should stay in place without the refresh effect.

I don't know if you noticed this enitre page refresh effect, it is kind of annoying for the reader. I saw this same behavior on some phpwcms sites, but not others. Does anybody know what causes this?

Here's a very nice site that refreshes only the content that changes while everything else stays in place:

http://www.parkeddomain.info/hollindia. ... hp?en_home

Locked