News Script Mod 2.0 for SP1.3-SP1.3.2 Need a news script but already have a YaBB board installed? No problem with this mod you can turn one of your boards, a category or even the whole forum into a news page. THIS MODS WORKS WITH SP1.3-SP1.3.2 How it works: The script will interpret all topics on the news board as news and the replys as comments. You can easily edit and delete news just by using the normal yabb functions. It is HIGHLY recommented that you install something like the "announcement" or the "MBC2" (More Board & Category Options v2.0) mod to restict posting to that board to admins and moderators. Installation: There are different ways to add these news to your homepage. With this mod, you can add it via SSI, PHP, Iframes or JavaScript: ----------------------------------------------------- If your host supports SSI, follow these instructions: ----------------------------------------------------- 1. install the mod and upload your changed SubList.pl, Admin.pl, Post.pl and english.lng 2. open News.pl and set the news settings at the begin of the file to fit your needs 3. upload News.pl into your Sources folder 4. upload news_template.html in the same folder as your YaBB.pl/YaBB.cgi. 5. Rename the page where you want the news to be displayed to *.shtml 6. Open your *.shtml file and add the following line where you want the news to be displayed: 7. Goto your admin center and press "Rebuild News-Script Cache" You may have to replace "./cgi-bin/yabb/YaBB.pl" by your board path and 'board=news' with the board id you want to be the news board. If you want a whole category to display, replace 'board=news' with 'cat=cat_id' where cat_id is the id of your category. If you want your whole board to display, leave the 'board=...' and 'cat=...' part out completely. ----------------------- If you want to use PHP: ----------------------- 1. install the mod and upload your changed SubList.pl, Admin.pl, Post.pl and english.lng 2. open News.pl and set the news settings at the begin of the file to fit your needs 3. upload News.pl into your Sources folder 4. upload news_template.html in the same folder as your YaBB.pl/YaBB.cgi. 5. add ONE of the following lines into your php file where you want the news to be displayed (e.g. if the first 6. Goto your admin center and press "Rebuild News-Script Cache" one doesn't work, just try the next one) You may have to replace "./cgi-bin/yabb/YaBB.pl" by your board path and 'board=news' with the board id you want to be the news board. If you want a whole category to display, replace 'board=news' with 'cat=cat_id' where cat_id is the id of your category. If you want your whole board to display, leave the 'board=...' and 'cat=...' part out completely. Note that it depends very much on your host whenever this works or not. It it possible that none of the above does work for you. In that case, please don't blame us and try a different methode (iframe and javascript should work for sure). ----------------------------- If you want to use an Iframe: ----------------------------- 1. install the mod and upload your changed SubList.pl, Admin.pl, Post.pl and english.lng 2. open News.pl and set the news settings at the begin of the file to fit your needs 3. upload News.pl into your Sources folder 4. upload news_template.html in the same folder as your YaBB.pl/YaBB.cgi. 5. add the following to your html page: 6. Goto your admin center and press "Rebuild News-Script Cache" You may have to replace "./cgi-bin/yabb/YaBB.pl" by your board path and 'board=news' with the board id you want to be the news board. If you want a whole category to display, replace 'board=news' with 'cat=cat_id' where cat_id is the id of your category. If you want your whole board to display, leave the 'board=...' and 'cat=...' part out completely. If you want to change the colors, simply edit bgcolor, textcolor and linkcolor in that tag. ------------------------------ If you want to use JavaScript: ------------------------------ 1. install the mod and upload your changed SubList.pl, Admin.pl, Post.pl and english.lng 2. open News.pl and set the news settings at the begin of the file to fit your needs 3. upload News.pl into your Sources folder 4. upload news_template.html in the same folder as your YaBB.pl/YaBB.cgi. 5. add the following to your html page: 6. Goto your admin center and press "Rebuild News-Script Cache" You may have to replace "./cgi-bin/yabb/YaBB.pl" by your board path and 'board=news' with the board id you want to be the news board. If you want a whole category to display, replace 'board=news' with 'cat=cat_id' where cat_id is the id of your category. If you want your whole board to display, leave the 'board=...' and 'cat=...' part out completely. Note that JavaScript must be enabled on clients, otherwise they won't see anything! ----------------------- Customizing the output: ----------------------- Most important for the layout is the news template (news_template.html). The template is for one news entry only and will be repeated if more than one entry is available). It works just like YaBB's original template: there are a couple of tags available which will get replaced by the real information. The following tags are avaiable: - displays the thread title - displays the creation time of the thread - author of the thread - message content - number of views - number of replies or "comments" - returns a text like "0 comments", "1 comment" or "10 comments" (note the missing "s" when number of replies is 1) - returns the url to the thread (use it as a link to view comments) - returns the url to the "reply" page of the thread (use it as a link to write a comment) - returns the url to the "send topic" page. Just put a around it in your template any you have a link - link to "print topic" page - returns the html code to display the thread's selected icon - the image src of the thread icon - displays the name of the last poster to this thread, left empty if 0 replies - displays the size of the message text in bytes - displays the board's name defined by "board=news" in the url - displays the id of the current category - displays the name of the current category - returns the html code to display the poster's userpic - the image src of the poster's userpic - returns the target for all links as it's set in News.pl - returns "_blank" by default. Edit $link_target to change it. Furthermore, there are some settings available to set the number of news, to cut long threads etc. You'll find them at the beginning of your News.pl. ------------------------------ Using multiple news templates: ------------------------------ It is possible to use multiple news templates. Todo this, simply create a new html template for your news and put the new file into the same directory as news_template.html. Please note that the filename of these new templates may only contain letters, _ and - and must end with .html for security reasons. Example: news_template2.html To call such additional templates, simply add a ";template=news_template2.html" to url in the tag you added into your homepage (where news_template2.html is the name of the new template). The javascript tag for example would then look like this: ---------------- Version History: ---------------- v2.0: - added topic cache => speeds things up A LOT!!! - rewrote large parts of the mod. Now opens a lot less files => speed up!!! - you can now use your whole forum as news page! Simply remove 'board=...' or 'cat=...' from your url - added new tags: * * * - updated default template to make use of new tags - updated documentation - moved language definitions to language file - all subs and vars now have a 'news_' prefix => less conflicts with other mods v1.3: - fixed not showing if last poster is a guest - added tag v1.2: - compatible to SP1.3 - a lot of code has been rewritten - now work with javascript & iframe - added new tags: * * * * * * * * * * * * - new options: * sort posts by last reply or creation time * cut message text after a set amount of words * cut message text after first paragraph - support for multiple news templates 1.1: New tag available: adds the topic icon to the news. Michael Prager http://www.boardmod.org Sources/SubList.pl %director=( 'news',"News.pl&News_Show", 'news_rebuildcache',"News.pl&News_RebuildCache", Sources/Admin.pl - $txt{'593'}
- $lang_news{'rebuild_title'}
Sources/Post.pl fopen(FILE, ">$datadir/$newthreadid.txt") || &fatal_error("$txt{'23'} $newthreadid.txt"); print FILE qq~$subject|$name|$email|$date|$username|$icon|0|$user_ip|$message|$ns|\n~; fclose(FILE); $mreplies = 0; require "$sourcedir/News.pl"; NewsCacheUpdate($currentboard,$newthreadid,stringtotime($date)); english.lng 1; %lang_news = ( 'comment' => "Comment", 'comments' => "Comments", 'more' => "read more", 'cat_not_found' => "Category not found", 'no_threads' => qq~
There are no threads in this board
~, 'invalid' => "Invalid argument set", 'chmod' => "Unable to generate news cache, can't create file $vardir/news_cache.txt - Make sure to chmod your Variables directory properly.", 'rebuild_text' => "The News-Script cache has been rebuild.", 'rebuild_title' => "Rebuild News-Script Cache", 'N/A' => "N/A" );