Using "Alias" in the navigation

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
pixelpeter
Posts: 45
Joined: Fri 27. Feb 2004, 16:00

Using "Alias" in the navigation

Post by pixelpeter »

If you have installed my Quick-Hack for rewriting this next hack should be also fine for you: Using Alias-Names in the Navigation

File: /include/inc_front/front.func.inc.php
Line: 511
function name: get_struct_data
desc:We will add the "acat_alias" to the struct wich is used for building the menu. I did this at the end of each field-list. You can copy the complete function from here

Code: Select all

function get_struct_data ($dbcon, $root_name="Home", $root_info="") {
	//returns the complete active and public struct data as array
	//so it is reusable by many menu functions -> lower db access
	$data[0] = array(	"acat_id"		=> 0,
						"acat_name"		=> $root_name,
						"acat_info"		=> $root_info,
						"acat_struct"	=> 0,
						"acat_sort"		=> 0,
						"acat_hidden"	=> 0,
						"acat_regonly"	=> 0,
						"acat_ssl"		=> 0,
						"acat_template"	=> 0 ,
						"acat_alias"	=> 0
						);
	$sql = "SELECT * FROM ".DB_PREPEND."phpwcms_articlecat WHERE ".
	   	   "acat_aktiv=1 AND acat_public=1 AND acat_trash=0 ORDER BY acat_struct, acat_sort;";
	if($result = mysql_query($sql, $dbcon)) {
		while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
			$data[$row["acat_id"]] = array(	"acat_id"		=> $row["acat_id"],
									"acat_name"		=> $row["acat_name"],
									"acat_info"		=> $row["acat_info"],
									"acat_struct"	=> $row["acat_struct"],
									"acat_sort"		=> $row["acat_sort"],
									"acat_hidden"	=> $row["acat_hidden"],
									"acat_regonly"	=> $row["acat_regonly"],
									"acat_ssl"		=> $row["acat_ssl"],
									"acat_template"	=> $row["acat_template"],
									"acat_alias"	=> $row["acat_alias"]
									 );
		}
		mysql_free_result($result);
	}
	return (sizeof($data)) ? $data : array();
}

File: /include/inc_front/front.func.inc.php
Line: 669
function name: build_levels
desc:In line 705 we will change the var $link to prepare for using aliase. You can copy this line from here. I left the original untouched to have the chanche to go back :?

Code: Select all

// $link = $link_to."?id=".$key.",0,0,1,0,0";
$link = $link_to."?".$struct[$key]['acat_alias'];
That's all folks !!! Is just so easy !! :D :) :D

This hacks works for the widly used {NAV_TABLE_COLUMN} replacement tag, but should be easily adopted.

Have fun !!!

[ p i x e l p e t e r ] (R)
Last edited by pixelpeter on Wed 3. Mar 2004, 14:16, edited 1 time in total.
cmslover
Posts: 86
Joined: Wed 18. Feb 2004, 16:17
Location: USA, Georgia, Atlanta
Contact:

Post by cmslover »

It does not work on my site :cry: I installed phpwms at a directory do I need to modify the code above?
pixelpeter
Posts: 45
Joined: Fri 27. Feb 2004, 16:00

Post by pixelpeter »

You have to install this Hack:
http://www.phpwcms.de/forum/viewtopic.php?t=1111

It's working with Version: phpwcms 1.1-RC2 2004-02-20
cmslover
Posts: 86
Joined: Wed 18. Feb 2004, 16:17
Location: USA, Georgia, Atlanta
Contact:

Post by cmslover »

pixelpeter wrote:You have to install this Hack:
http://www.phpwcms.de/forum/viewtopic.php?t=1111

It's working with Version: phpwcms 1.1-RC2 2004-02-20

Yes, I already installed the re-write hack and it works fine. ( Thanks again )
Then I installed the ALIAS code above but it doesn't work with the ALIAS I named (in Category Alias )
You think installing phpwcms in a directory not root domain maybe an issue ?

system: Linux server: Apache/1.3.28 (Unix) mod_ssl/2.8.15 OpenSSL/0.9.6b FrontPage/5.0.2.2510 PHP/4.3.2 mod_throttle/3.1.2
php: v4.3.2

Thanks
pixelpeter
Posts: 45
Joined: Fri 27. Feb 2004, 16:00

Post by pixelpeter »

If you're running phpwcms in a subdirectory under your Document root you'll need a bit tweaking to make it work !!!

I moved the complete phpwcms Installation to following directory under the DocumentRoot of the webserver /just/another/directory/

So Directory Structure would be something like this

/just
--/another
---/directory
----/.htaccess
----/include
----/phpwcms.php
----/all other stuff from the phpwcms installation


Change the include/conf.inc
You need to change the var $phpwcms["root"] to /just/another/directory/


Change the .htaccess

Code: Select all

RewriteEngine on
RewriteBase /just/another/directory/
RewriteRule ^([0-9]*)\.([0-9]*)\.([0-9]*)\.([0-9]*)\.([0-9]*)\.([0-9]*)\.html$ /just/another/directory/index.php?id=$1.$2.$3.$4.$5.$6

RewriteRule ^([a-zA-Z0-9_]*)\.html$ /just/another/directory/index.php?$1 
Well, that's everything. Wasn't that easy too ?? :lol: :o :)

EXPLAINED:
You need to add the complete path starting from DocumentRoot to the RewriteBase and to the right side of your rewrite rules wich is in this case: /just/another/directory/

Have fun !!
[ p i x e l p e t e r ] (R)
cmslover
Posts: 86
Joined: Wed 18. Feb 2004, 16:17
Location: USA, Georgia, Atlanta
Contact:

Post by cmslover »

I tried changing the path to full path like you said /web/domain.com/directory and got error "404 file not found, so I changed it back to /directory only and the rewrite is working again. BUT the Alias still does not work :(

I don't understand, if the rewrite mode is working, how come the Alias does not???? It doesn't make sense as the ALIAS Code above has nothing to do with the path?
pixelpeter
Posts: 45
Joined: Fri 27. Feb 2004, 16:00

Post by pixelpeter »

Where is your DocumentRoot in /web/domain.com/directory ??

For Example: FullPath to my Documents is

/usr/local/httpd/htdocs/kunden/web1/html/mydomain.com/just/another/directory/

The DocumetRoot of the webserver points to mydomain.com

So we need to add everything after this to our path:
/just/another/directory/
cmslover
Posts: 86
Joined: Wed 18. Feb 2004, 16:17
Location: USA, Georgia, Atlanta
Contact:

Post by cmslover »

pixelpeter wrote:Where is your DocumentRoot in /web/domain.com/directory ??

For Example: FullPath to my Documents is

/usr/local/httpd/htdocs/kunden/web1/html/mydomain.com/just/another/directory/

The DocumetRoot of the webserver points to mydomain.com

So we need to add everything after this to our path:
/just/another/directory/
My full path is /hsphere/local/home/web/mydomain.com/phpwcms

if I leave the whole path like that or like this /mydomain.com/phpwcms
I get error 404

If I just leave only /phpwcms the rewrite runs just fine except the alias.
pixelpeter
Posts: 45
Joined: Fri 27. Feb 2004, 16:00

Post by pixelpeter »

Maybe there's another rule in background doing things we don't know ?? :? :shock:

Maybe some strange Server-Konfiguration :shock:

Sorry. I can't say anything more ;-((

Maybe you can send me your httpd.conf & .htaccess-file so I have more information

Sorry :?: :?:
cmslover
Posts: 86
Joined: Wed 18. Feb 2004, 16:17
Location: USA, Georgia, Atlanta
Contact:

Post by cmslover »

Hi Pixelpeter, you have done a wonderful hack! no need to say sorry :D

Anyway,
Here is my.htaccess file

Code: Select all

php_flag magic_quotes_gpc Off
php_flag register_globals Off
RewriteEngine on 
RewriteBase /house/ 
RewriteRule ^([0-9]*)\.([0-9]*)\.([0-9]*)\.([0-9]*)\.([0-9]*)\.([0-9]*)\.html$ /house/index.php?id=$1.$2.$3.$4.$5.$6 

RewriteRule ^([a-zA-Z0-9_]*)\.html$ /house/index.php?$1
The other file, where to look at? I have shell acess but I don't see it ?

Thanks
Last edited by cmslover on Thu 4. Mar 2004, 18:29, edited 2 times in total.
pixelpeter
Posts: 45
Joined: Fri 27. Feb 2004, 16:00

Post by pixelpeter »

One more thing:

Can you include this code-snippet in index.php just before the ending </body>-Tag and send me the output ?

Code: Select all

<pre>
GLOBALS:<br>
<?print_r($GLOBALS)?>
</pre>
cmslover
Posts: 86
Joined: Wed 18. Feb 2004, 16:17
Location: USA, Georgia, Atlanta
Contact:

Post by cmslover »

File is too big, I may have to send it to you via email
Last edited by cmslover on Thu 4. Mar 2004, 19:10, edited 2 times in total.
pixelpeter
Posts: 45
Joined: Fri 27. Feb 2004, 16:00

Post by pixelpeter »

Please send me your front.func.inc.php

.. I maybe have a slight idea
frold
Posts: 2151
Joined: Tue 25. Nov 2003, 22:42

Post by frold »

cmslover plz delete that post....!!!

eg. make a link to a text file instead....
http://www.studmed.dk Portal for doctors and medical students in Denmark
cmslover
Posts: 86
Joined: Wed 18. Feb 2004, 16:17
Location: USA, Georgia, Atlanta
Contact:

Post by cmslover »

Sorry, file is to big
Last edited by cmslover on Thu 4. Mar 2004, 19:11, edited 1 time in total.
Post Reply