PDA

View Full Version : Will pay $2


bobby9101
09-01-2006, 08:59 PM
I am looking for a super simple sitemap.
Somgthing that will simply grab all the categories and display them Alphabetically, with sub-cats under Main Cats. I need this to allow an infinite number of sub cats.
However I only need it like this:
MAIN CAT 1
Sub Cat 1
ALL OF SUB CAT 1's Child Cats
Sub Cat 2
Main Cat 2...
blah blah blah

it is very simple...
here is what I ahve so far:
___________TPL
{strip}
{capture name="title"} - {l}Directory sitemap{/l}{/capture}
{capture assign="in_page_title"}{l}Directory sitemap{/l}{/capture}
{capture assign="description"}{l}Directory sitemap{/l}{/capture}
{include file="header.tpl"}
{include file="top_bar.tpl"}
{assign var="incr" value=1}
{assign var="current_column" value=1}
{* Categories *}
<div class="sidecats">
<h3>Directory Categories</h3>
<ul>
{foreach from=$cats item=cat name=cats}
<li><b><a href="{$current_path}{$cat.TITLE_URL}.html">{$cat.TITLE}</a></b>
</li>{/foreach}
</ul>
</div>
{include file="footer.tpl"}
{/strip}
__________PHP
<?php
require_once 'init.php';
$cats = $db->GetAll("SELECT * FROM {$tables['category']['name']} WHERE STATUS=2 AND `PARENT_ID` = 0 ORDER BY `TITLE` ASC");
$tpl->assign('cats', $cats);
echo $tpl->fetch('sitemap.tpl');
?>

clasione
09-02-2006, 04:51 AM
I would be interested in seeing the outcome on this aswell... :)

VSDan
09-02-2006, 06:39 AM
Try this:

sitemap.php
(code borrowed from 'get_categs_tree' function in include/functions.php)

<?php

require_once 'init.php';


function sitemap($id=0){
global $db, $tables;
static $categs =array("0"=> "<a href=\"\">Top</a><br>\n");
static $level =0;
$rs = $db->Execute("SELECT `ID`, `TITLE`, `TITLE_URL` FROM `{$tables['category']['name']}` WHERE `PARENT_ID` = " . $db->qstr($id). " AND `STATUS` = '2' AND `SYMBOLIC` <> '1' ORDER BY `TITLE`");
$level++;

while(! $rs->EOF){
$categs[$rs->Fields('ID')]= str_repeat('&nbsp;&nbsp;&nbsp;', $level -1). "<a href=\"" . SITE_URL . $rs->Fields('TITLE_URL'). ".html\">" . $rs->Fields('TITLE'). "</a><br>\n";
sitemap($rs->Fields('ID'));
$rs->MoveNext();
}
$level--;
return $categs;
}

$categs = sitemap();

$tpl->assign('categs', $categs);
echo $tpl->fetch('sitemap.tpl');

?>

sitemap.tpl
Content visible to registered users only.

Subcats are indented accordingly with spaces. You can see demo here:

http://www.monster-submit.com/directory/sitemap.php

clasione
09-02-2006, 09:24 AM
Needs a little tweeking, but it works! :)

Big ups to the contributor...... We need more people like you here....

bobby9101
09-02-2006, 04:43 PM
ok... doesnt quite work for me.
It displays the categories correctly... however
when i click on a link it goes to 127.0.0.1/directoryfolderCategoryURL.html

1. there is no slash between the directory folder and the category url
2. when i click on a subfolder it doesnt have the parent folder in front of it in the url
3. I am using V2.0
4. I am using the .html mod
5. if/when you get it fixed, where to send the $2

VSDan
09-02-2006, 07:06 PM
Content visible to registered users only.

Can you post URL to your sitemap.php.

bobby9101
09-02-2006, 07:07 PM
nah it is on my localserver without web permission

thompson
09-02-2006, 07:38 PM
somewhere in this line

<a href=\"" . SITE_URL . $rs->Fields('TITLE_URL'). "\">" . $rs->Fields('TITLE'). "</a>

is an error. backslash lost ?

VSDan
09-02-2006, 07:48 PM
Easy fix to both - will have shortly. I guess I should not have been coding last night after a few drinks =)

VSDan
09-02-2006, 09:52 PM
Done =) If someone can point me to HTML Mod thread, I will implement and test.

thompson
09-03-2006, 09:27 AM
can you post the changes here, please ? thanks.

subcats dont show the cat in the url.

VSDan
09-03-2006, 09:41 AM
Here you go (revised sitemap.php):

Content visible to registered users only.

May require tweaking to be fully portable, but works on my server as is.

thompson
09-03-2006, 01:54 PM
works very good. take a look at the above link i posted.

where can i do a dot before category and a - for a subcat ?

thanks for your excellent work.

VSDan
09-03-2006, 04:37 PM
Try this:

Content visible to registered users only.

thompson
09-03-2006, 05:40 PM
thanks, works fine.

i think this is a good thread for Mod forum.

VSDan
09-03-2006, 05:57 PM
Glad to hear it's working now, and you're welcome =)

mmastation
09-08-2006, 08:11 PM
when I put in the code dan posted I lose the whole sitemap. was that supposed to be only a code change somewhere?

Kaz
10-16-2006, 11:27 PM
We had a problem with the file finishing with .html using mod rewrite on PhpLD v2 so we updated the code to remove the HTML, works fine now.

Content visible to registered users only.

Ours needs a bit of tweaking, maybe if we could get it into to columns ;)

stake
11-14-2006, 08:16 PM
PlZ me need code sitemap.tpl

KoverPL
11-19-2006, 09:04 PM
so can someone just write the code for sitemap.php and sitemap.tpl in one post ? thx :) I use 3.0.6

MikeK
02-09-2007, 10:25 PM
Hi,

I tried this mod in v3.1 and it works very well. Now I like to have more! ;)

Is it possible to add the "subpages" (page-2.html, page-3.html)? To increase the internal linking.

o Top
o Cat A
o Cat B
- Subcat BA [2] [3]
- Subcat BB [2]
o Cat C

Thanks,

Mike

shadav
02-10-2007, 12:33 AM
hey thanks dan this works great on v2.1

[edit] question...what about getting it to display like

Cat -> Sub Cat -> Second Sub Cat
Cat -> Sub Cat
example:
Auto
Auto -> Auto Parts
Auto -> Auto Sales -> Dealerships
Auto -> Forums

VSDan
02-10-2007, 04:49 AM
Content visible to registered users only.

Hi Mike:

Something like this:

http://www.monster-submit.com/directory/sitemap.php

eddie43302
02-10-2007, 06:08 PM
I got a quick question for you dan. Is there anyway you can make the add category, category selection ajax?

VSDan
02-10-2007, 06:39 PM
Are you referring to the [Suggest Category] mod?

MikeK
02-10-2007, 06:46 PM
Content visible to registered users only.

Yes! That looks good.

VSDan
02-10-2007, 06:59 PM
You can find it here:

http://www.monster-submit.com/directory/distr/sitemap.zip

MikeK
02-10-2007, 09:20 PM
Hi Dan,

thank you for this. It works very good, but I made some changes in the sitemap.php:

Content visible to registered users only.my version:
Content visible to registered users only.Ciao,
Mike

VSDan
02-10-2007, 11:00 PM
Most excellent, I've incorporated those into the mod. However, I changed

Content visible to registered users only.

to:

Content visible to registered users only.

This takes into consideration those who have phpLD installed in a subdirectory instead of top root directory.

MikeK
02-11-2007, 01:55 PM
Good idea! I put into my code.

navjotjsingh
04-30-2007, 05:09 AM
Thanks for the Mod..It works perfectly in 3.2 as well. But I would like one thing.

Now with 700+ Categories list becomes very long to scroll down. Any way that we can show list in 2 or 3 columns based on limited no. of categories to be shown in a column..say around 400 categories in a single column?

Searchnology
05-06-2007, 06:59 AM
Content visible to registered users only.

I appreciate the mod as well....the multiple column idea is good too.

Robert Allen
05-07-2007, 01:19 PM
This mod doesnt work...do you need version 3.x for it? I have version 2.

Rob