PDA

View Full Version : How to add content to each Category?


gmschmitz
04-23-2006, 05:28 AM
I'm looking to add a few paragraphs to each category page. I'm new to php and was thinking it could be done by maybe creating a .tpl file for each cat with the content that I want to add and then somewhere in the main.tpl be able to add if cat=catname include catname.tpl. Does this make any sense of am I just way off.

anon
04-23-2006, 05:47 AM
in your admin panel, there is a section to which you can provide a 'description'

if you go in and modify your categories, you can add that description, and then in your .tpl, you wold reference it something like: {$category.DESCRIPTION}

Rob

fjean
04-23-2006, 06:06 AM
in main.tpl

Content visible to registered users only.

gmschmitz
04-23-2006, 06:07 AM
Thanks Rob, I think that is going to work, the only problem is the description will only let me enter in a few lines and I was looking for a few paragraphs. Do you know where I can change the length, I thought I found it but all it did was make the box bigger for me to input all that text, but when I saved it it still only showed the same amount of words.

Thanks in advance,
Gary

fjean
04-23-2006, 06:07 AM
I love this script. I have no knowledge of programming and I was able to help. See it live at http://www.isins.com

gmschmitz
04-23-2006, 06:12 AM
It's all in where you put {$cat.DESCRIPTION} I seen mine come up that way first, but I was looking to add it only to the actual cat page. I found where to put it, but it just wouldn't add all the text I want.

fjean
04-23-2006, 06:15 AM
Content visible to registered users only.

I can hear the search engine spiders now.. Text Text Text

man, we are geniuses. I haven't seen a phplinkdirectory site with the category descriptions posted like we just figured it out.

anon
04-23-2006, 06:23 AM
Trust me, there are quite a few. ;)
You just need to get aaround a lot more.

Rob

gmschmitz
04-23-2006, 03:46 PM
So I tried to go in and change the database from 255 characters to more, but anything I entered wouldn't work if I put it back to 255 it worked but if I put in any other number it gave me an error. Any suggestions??

Fred
04-23-2006, 03:53 PM
You cant just change the nummber you need to change the type aswell
so if you change the type from varchar to text it should work...

gmschmitz
04-23-2006, 04:16 PM
I tried that and no luck also, I'm still getting an error.

fjean
04-23-2006, 05:46 PM
i'm using phpld version 3.02

just take a look at my site at http://www.isins.com

and here's my main.tpl
Content visible to registered users only.

I hope that help you

gmschmitz
04-23-2006, 06:00 PM
I'm not sure you understand, I have it working, I only want it to display the description on the Category page itself. Like this at http://www.us-realestatedirectory.com/Alabama_/ the problem is I want 2-3 paragraphs of content.

Maybe you haven't noticed buy take a look at your page http://www.isins.com/Computers_and_Internet/ and you'll see that it cut it off and didn't include all text because you went over 255 characters. I think Vchar in the database has a max of 255, I've tried to make it be more but it won't let me. I'm still learning mysql so maybe I'm just doing something wrong.

Gary

thompson
04-24-2006, 12:35 PM
take a look at this:

{topic moved or deleted}

i think it solved your problem.

gmschmitz
04-24-2006, 08:21 PM
Thanks Tompson, That sounds like what I need, I gave it a shot and got some smarty errors, but that is definately what I'm trying to do. Thanks again, I'll keep at it.

Gary

jeeplaw
05-07-2006, 12:51 PM
I tried adding the {$cat.DESCRIPTION} to my main.tpl for 3.0.4 and it doesnt' seem to be working..any other ideas?

brk
05-27-2006, 07:02 PM
I need to follow this link but I can't. Is there anybody that can please help me?

Thanks! :)

thompson
05-28-2006, 10:17 AM
ok. here it is:

copy the following text in an php file called description.php or something like that an put it in the folder "includes". after that, you have to run the script in browser:

<?php
/************************************************
*
* Author: Casey Wilson / Ap0s7le
* Email: at - ap0s7le.com
* Website: www.ap0s7le.com
*
* This script has been used on quite a few
* PHPLD installs, let me know if you have
* any issues.
*
* It could have better error handling, but
* normally I'm the one using it, so it didn't
* matter haha
*
* INSTALL:
* Place this in your include folder, after you
* run it, please rename it or remove it from
* the site so no one else could use it on your
* database.
*
************************************************/


// Include the initialization info
include('init.php');

// Add a new field
$sql = "ALTER TABLE {$tables['category']['name']} ADD DESC_LONG TEXT NULL AFTER DESCRIPTION";

// If that completed alright, then lets continue on, otherwise DIE DIE DIE!!
if (!$db->Execute($sql))
{
die (mysql_error());
}

// Now, lets grab the DESCRIPTIONS, and input them into the new field
$sql = "SELECT ID, DESCRIPTION FROM {$tables['category']['name']}";

// Pull the results
$data = $db->GetAll($sql);

// Now lets do the ole switch arooo
foreach($data as $row)
{
// Update SQL, it now switches the two DESCRIPTION's around
$db->Execute("UPDATE {$tables['category']['name']} SET DESC_LONG = '" . $row['DESCRIPTION'] . "' WHERE ID = {$row['ID']}");
}

// Now, for the final step we'll rename DESCRIPTION to DESCRIPTION_OLD, and DESC_LONG to DESCRIPTION
$db->Execute("ALTER TABLE {$tables['category']['name']} CHANGE DESCRIPTION DESCRIPTION_OLD VARCHAR( 255 ) NULL DEFAULT NULL") or die (mysql_error());

$db->Execute("ALTER TABLE {$tables['category']['name']} CHANGE DESC_LONG DESCRIPTION TEXT NULL DEFAULT NULL") or die (mysql_error());

echo "All went fine... I guess ;)";

?>

thats all.

brk
05-28-2006, 05:15 PM
Well, first of all thank so much for your time.

Unfortunately I did what you said, or at least I think I did, but it doesn't work when I call description.php in my browser.

Any idea why?

Thanks very much!

:)

anon
05-28-2006, 05:48 PM
Hey Gary,

How about trying to:

1: back up your database.

****NOTE**** I DO NOT GUARANTEE NOR DO I KNOW THE OUTCOME FROM DOING THIS

2: Run This AT YOUR OWN RISK

ALTER TABLE`PLD_CATEGORY` DROP INDEX `PLD_CATEGORY_DESCRIPTION_IDX` ;
ALTER TABLE `PLD_CATEGORY` CHANGE `DESCRIPTION` `DESCRIPTION` LONGTEXT CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL ;
ALTER TABLE `PLD_CATEGORY` ADD INDEX `PLD_CATEGORY_DESCRIPTION_IDX` ( `DESCRIPTION` ( 1500 ) ) ;

If all executes well, you should have a DESCRIPTION Field defined as longtext with length of 1500 characters.

GL

Rob

gmschmitz
06-14-2006, 03:54 PM
**Bump**

I noticed that members were asking about this again, so I dug it up. It's been so long since I have done it, but I do know that I followed what thompson had said to do and it worked. I remember having to do it twice because the first time I did it it changed the description of the links not the category, but looking at this code below it appears to be correct for the category.

copy the following text in an php file called description.php or something like that an put it in the folder "includes". after that, you have to run the script in browser:

Content visible to registered users only.

kentuckyslone
06-28-2006, 11:50 PM
Thank you very much!

This is extremely useful. I am running 3.0.4 and ran the query in phpmyadmin. Now I am able to have quite long descriptions when I need them.