Title: Story Tags, Story Tag Cloud
Version: 0.6b
Description: Adds the ability for readers to tag stories. Tags create a new level of connection between your stories. Similar stories can be quickly found by compairing tags that match. Readers can use the tags to focus in on what they are most interested in.
This mod provides basic tagging function in the viewstory.php file. It also creates an independent tag cloud page (tags.php) and a block to include on your index page.
This mod uses the freetag API to handle the back-end tag management. The entire system is independent of eFiction, but very easy to tie into any database.
Step 1 : Download the following package and extract. Copy tags.php into your root eFiction directory. Copy the /modules/tags/ directory and all it's contents into the /modules/ directory.
Optional: copy /blocks/tags/ into your blocks directory.
http://www.necrotania.com/Download/efic_tags/storytag.zip
Step 2: Login to your archive as a admin and navigate to yourise.com/yourefic/modules/tags/install.php. This will apply the necessary database changes. This is a new addition so please verify that there are no errors during the run
Step 3 : Add {ft_tags} to your skin where you wish the tags to be displayed and entered. I added it to the top of viewstory.tpl.
Optional: Add {ft_related} to your viewstory.tpl file to show related stories. This relation is based on number of matching tags
Step 4: Optional: From your admin panel, navigate to Blocks and initialize the Tags block. Then add the {tags_title} and {tags_content} to your index page to display the tag cloud on your main page
Demo Links:
Tag Cloud - http://www.necrotania.com/eFiction/tags.php
Tag Viiew with Similar Tags - http://www.necrotania.com/eFiction/tags?tag=fantasy
Tag Cloud Block - http://www.necrotania.com/eFiction/
Tag input (top) and Similar Stories (bottom) - http://www.necrotania.com/eFiction/viewstory.php?sid=1120
Version History
0.1a (8/22/2007):
Initial Release
0.2a (8/22/2007):
Corrected query in tags.php to use definitions from queries.php.
Added missing closing bracket to variables.php edit
0.3a (8/22/2007):
Alters mod to use hook in viewstory.php.
Changed location of freetag directory. Once you upgrade you can remove the directory from the eFiction root folder
Removed variable.php modification and placed the code in the module/tags/ directory for the hook
0.4a (8/23/2007):
Added "Similar Tags" to bottom of tags.php when viewing tags. There is a bug with this that causes some warnings when there are no similar tags found.
Added shuffle_me function to tags.php to randomize the Similar Tag output.
0.5b (8/23/2007):
Upgraded version to Beta status.
Fixed warning bug when viewing a tag with only 1 related tag. Related tags will only randomize when there are at least 3
Added "Related Story" variable to viewstory.tpl. It will list the top 3 similar stories based on matching tags
Added Tag Cloud block to show the tag cloud on any page.
0.6b (8/24/2007):
Made some major changes to the viewstory.inc.php file to improve the overall code and reduce duplicate effort
Added escapestring function to sanitize all inputs
Added feature to allow story authors to delete tags from there stories, no matter who put them there
Altered tag deletion function to allow author tag deletion.
Added isMember checking to script to prevent non-users from adding or deleting tags
Added install.php script to execute the SQL queries. located in /modules/tags/ directory. Will only run for an admin.
Is it possible to add the table prefixes on SQLing?
(Unsure as to where it gets affected in the files)
eta: Testing on my demo site.
variables.php gives the error "Parse error: syntax error, unexpected $end"
So:
else {
$ft_output .=" Be the first to add a tag to this story ";
}
} // added
$ft_output .="<br />";
Works.
And
A fatal MySQL error was encountered.
Query: SELECT stories.*,stories.sid, author.username as penname, UNIX_TIMESTAMP(stories.date) as date, UNIX_TIMESTAMP(stories.updated) as updated FROM (vb_user as author, fanfiction_stories as stories) WHERE author.userid = stories.uid AND stories.validated > 0 AND stories.sid = 1 LIMIT 1
Error: (1146) Table 'accionu_demo.vb_user' doesn't exist
Appears when clicking on a tag. (adding it is fine, though)
I'm assuming this is because you have it with VB. π
Eta II:
To fix that ...
tags.php -> ~line 63
$taglink = dbquery("SELECT stories.*,stories.sid, author.penname as penname, UNIX_TIMESTAMP(stories.date) as date, UNIX_TIMESTAMP(stories.updated) as updated FROM (".TABLEPREFIX."fanfiction_authors as author, ".TABLEPREFIX."fanfiction_stories as stories) WHERE author.uid = stories.uid AND stories.validated > 0 AND stories.sid = ".$tagsid." LIMIT 1");
It was mainly trial and error ... but it works for me right now.
archive:
site:
Available for skin/mod commission! π
ACK!! Totally missed the SQL queries. Bad me...bad!!
I will get that corrected and uploaded. Thanks for hunting down the bugs π
For the variables.php edit I missed the final }. Where you put it is fine, but it will do some unnecessary work as a result. Put that } after the last line and it should work. I will edit the post to get that updated.
I'm not good with the PHP so I decided to put it where Notepadd++ was giving me the +/-. π
I'm editing it to make it a touch semantic, then I'll show you and see if it's okay?
archive:
site:
Available for skin/mod commission! π
Script has been updated. The query in tags.php is now correctly using definitions setup in queries.php, so it should work no matter if there is a bridge or not.
Let me know how this version works for you.
Brainstorming here for a moment.
I am wondering if the code that is currently executed in variables.php would be in a better spot by using the hook in viewstory.php. This would put the execution at the end of the script so I can capture the story owner ID (so authors can delete tags from there stories). I am going to have to play around with this a bit and see what works best.
Edit - Test has gone very well, so I will be adjusting the instructions to use the hook in viewstory.php. New version should be up in a bit.
Updated to add a "Similar Tag" function when viewing an individual tag. This uses one of the api's functions, weighing related tags based on number of objects that share the tags. Higher weight increases the size of the tag.
There is a small bug that causes two warnings if there are no related tags. I am working on this for the next version.
There is also a "Related Object" function that I am working to add to viewstory.php. What it will do is allow us to generate a list of related stories based on shared tags and strength of the tags. This will be grouped into a tpl variable to be included in viewstory.php output.
To upgrade from previous version just overwrite the files.
I am also putting together a very basic installer to run the sql queries.
Oh tags!! Wonderful, I've wanted to have tags for eFiction for ages. As soon as the weekend is arriving I'll be trying that one.
I am hoping to have an install script by then so you will not have to run MySQL queries by hand.
The next version is in testing on my site. It fixes the related tag issue and adds a "Similar Story" tpl variable. What this does is check for other stories that share the same tags as the one you are looking at and shows them in a list on the viewstory page. The idea is to allow people to see stories that may also interest them.
And I thought I was the only person who looked at eFiction and said "We needs tags with this..." π
I can already see that my users will love this. I certainly find tags very useful!!
Has the zip been updated with your latest fixes?
Just updated to latest version.
Fixed the warnings on stories with less than 2 tags
Added related story variable
Added tag cloud block that can be included on the index page.
I will get the instructions updated now.
http://demo.accio.nu/efic/tags.php for semantic-ism. Though, I have yet to use the updated version.
I'm still in the midst of contemplating on whether my users may benefit with this or find it too bulky for our archive. π
archive:
site:
Available for skin/mod commission! π
I will be eventually adjusting the output to allow for easier skinning, just not there yet π Looks really good on your test site, I like how you set it all up.
Next version is mostly bug fixes. I am testing it now and will have it posted tomorrow.
- Added member check to all forms. They will no longer display unless the user is logged in.
- Form processing also checks for member login
- Inputs are now run through escapestring function to sanitize the inputs
- Cleaned up the code a bit, had 2 areas checking for the same things.
- Added ability for author to remove any tag from there story.
- Added basic install script to automate setup, no more running the SQL by hand.
Once I test it out I will post the code....probably tomorrow during my morning coffee π
Edit: It is morning, I have my French Vanilla coffee (Milk, 2 sugars, bit of cinnamon and chocolate flake) and the next version has been posted. Not sure what other features to add...possible something for people to track the tags they added in there profile. Suggestions are welcome π
I am currently working on a panel for the user page. It shows the tags that a user submitted. It works but I am trying to figure out how to handle the skinning...so it may be a few days before I release it.