Tammy (or who ever knows), I need your help.
I want to have the ability that the admin is entering an URL for each or several categories.
The purpose is that when there is an URL filled in the field of the category, that the user can click on it and a new window opens (in the ficdom.net sample, to navigate to the forum about that category).
I made the needed change in the database:
Table: fanfiction_categories
Field name: url
Field type: varchar(100)
In the file admincategories.php, I made the following changes:
Look for:
$catresult = "UPDATE ".TABLEPREFIX."fanfiction_categories SET category = '".addslashes(descript($_POST['category']))."', description = '".addslashes(descript($_POST['description']))."', locked = '$locked', parentcatid = '".$_POST['parentcatid']."', image = '".$_POST['image']."', leveldown = '$leveldown', displayorder = '$displayorder' WHERE catid = '".$_POST['catid']."'";
and replace with:
$catresult = "UPDATE ".TABLEPREFIX."fanfiction_categories SET category = '".addslashes(descript($_POST['category']))."', description = '".addslashes(descript($_POST['description']))."', locked = '$locked', parentcatid = '".$_POST['parentcatid']."', image = '".$_POST['image']."', url='".$_POST['url']."', leveldown = '$leveldown', displayorder = '$displayorder' WHERE catid = '".$_POST['catid']."'";
and look for:
<INPUT type='text' class='textbox=' name='image'".(!$new && $cat1['image'] != "" ? "value='$cat1[image]'": "")."> <A HREF=""#"" class="pophelp">[?]<span>"._HELP_CATIMAGE."</span></A></div>
and after that add:
<div><label for='url'>Category URL: </label>
<INPUT type='text' class='textbox=' name='url'".(!$new && $cat1['url'] != "" ? "value='$cat1[url]'": "")."></div>
blockscategoriescategories.php
Look for:
"<a href=""browse.php?type=categories&catid=".$categories['catid'"]."">".$categories['category']."</a>", $categories['numitems'], stripslashes($categories['description']));
Replace with:
"<a href=""browse.php?type=categories&catid=".$categories['catid'"]."">".$categories['category']."</a><a href="'".$categories['url'"]."' target=_blank> (...)</a>", $categories['numitems'], stripslashes($categories['description']));
Look for:
$tpl->assign("categorytitle", "<a href=""browse.php?type=categories&catid=".$categories['catid'"]."">".$categories['category']."</a>");
Replace with:
$tpl->assign("categorytitle", "<a href=""browse.php?type=categories&catid=".$categories['catid'"]."">".$categories['category']."</a><a href="'".$categories['url'"]."' target=_blank> (...)</a>");
browsecategories.php
Look for:
$cat->assign("link", "<a href=""browse.php?type=categories&catid=".$cats['catid'"]."">".$cats['category']."</a>");
Replace with:
$cat->assign("link", "<a href=""browse.php?type=categories&catid=".$cats['catid'"]."">".$cats['category']."</a><a href="'".$cats['url'"]."' target=_blank> (...)</a>");
So far, so good.
Now the only one left are the category links in the function catlist from the php file corefunctions.php.
What I understand from that function is that it builds an array of category links.
if(!is_array($catid)) $catid = explode(",", $catid);
I don't understand the above statement. When it is not an array, then you use the function explode!? When it is not an array, it is a category id! Why use explode?
Where is the field 'name' come from:
$catlist[$thiscat]['name']
I tried to use the field url (the one I created in the category table)to see if it crashes:
$catlist[$thiscat]['url']
To my surprise it does not crash, but the actual value is not the URL I entered, but the link itself.
How many admins you got? You might want to sanitise that data if there's a lot modding.
What are the problems?
archive:
site:
Available for skin/mod commission! 🙂
Hi Jenny.
There are many admins.
The problem is where can I fond the code where the categories are displayed?
I cannot find it!
If I know where the categories are being displayed in the code (in category listing, in the search, in the story listing, etc.), I display the link after the name of the category.That sounds easier then I thought, because I could not find it!
We are talking about bridging towards other software like SMF, but the only thing it does is a link tot he forum and a shared userbase.
But there is no integration what-so-ever between the two of them.
One of my mods wants to have an integration between the eFiction and SMF, starting with the categories, but he wants it also extended to the user profile, stories, classifications, characters, the whole bunch.
Hard coding it is not an option, but when it is possible for the admin (or author even) to add a link to an external site (in our case the SMF), and when the link is entered, the eFiction must display the link, which will result in opening a (new) window with that site. Others can use the link to point to another site.
It's displayed in many, many places.
includes/storyblock.php
includes/seriesblock.php
viewstory.php
Any modules you have will also likely have places you'll need to edit.
Thanks Tammy.
There is only one left and that is the function catlist in corefunctions.php.
That function builds a list of category links, but I have a question about that.
In that function, the statement is being used
$link = $catlist[$thiscat]['name'].$link;
Where does it get the field 'name' from?
I have a (new) field in the category table, which is called 'url'. How do I get the value of that field 'url' and where does the field 'name' come from?
I updated the first post here of this topic with the latest code changes, except the catlist function, which is many times called in the efiction code. When we solve that, the link of the category is working everywhere required.
I've a test site for this category link (and for other mods and blocks).
http://development.ficdom.net
There is also a test account (as admin):
Username: test
Password: test
It gets it wherever the $catlist variable is built, and that could be a couple places. I'm not at my computer right now so I can't look at the files to give you a better idea of where to look.
Tammy?
Can you help me out here with the locations of the $catlist variable?
Because it takes me ages. In the mean while I can finish the Best Fic and Best Author block
It's probably in corefunctions.php. You can do exactly what I would do which is search the files.
