Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: Keith Tysinger on April 27, 2009, 10:57:58 PM

Title: Free Content
Post by: Keith Tysinger on April 27, 2009, 10:57:58 PM
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=1778)

Free Content
Version: 1.2
Mod by J. Keith Tysinger


Demo: Madcoder.biz/forum (http://madcoder.biz/forum/)

For SMF 2.0 RC1
Now works with SMF 2.0 RC3 and the new Curve theme (download freecontent1_2.zip). See notes at bottom of this post.

Free Content grabs a daily "word of the day" from the following websites:

1) Merriam-Webster (vocabulary builder with pronunciation)
2) The Quotations Page (famous quotes)
3) Biblegateway.com (daily Bible verse)


The member's profile form is modified to allow a user to choose which, if any, module to display. It also allows the member to display the content in random order.


The admin center allows the moderators to:

1) Turn the mod on/off

Important!:

This Mod requires that PHP's file_get_contents() be available to read the external RSS feeds. Otherwise, this MOD will not work on your server. Some servers disable this feature.

This mod is not a simple RSS reader. The RSS feeds are heavily formated to work well in SMF.


Special note about this script:

Please support this mod. If you find this mod useful, please send a few dollars to the author:
[email protected] (https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=Keith%2eTysinger%40gmail%2ecom&lc=US&item_name=Buy%20me%20a%20%2e%2e%2e&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted)



If you liked this mod, please check out my other one: Buy me a Drink (http://custom.simplemachines.org/mods/index.php?mod=1750)


SMF 2.0 RC3 Notes:
To work well in the new Curve theme, I suggest turning the News feature off in your admin panel under Config-> Current Theme. Advanced users may want to move the search feature form to the very top and replace the site slogan, or move the search feature to the left hand side of the screen. This may be more appealing visually, but certainly not necessary.


For installation of this or any other script, please contact me via contact form @ www.MadCoder.biz
Title: Re: Free Content
Post by: Keith Tysinger on April 28, 2009, 02:33:56 AM
Some additional notes on this mod:

The Bible verse is from the NIV version of the Bible.

----------------------------------------------------------

Technical notes you can (and probably should) ignore:

This mod reads a RSS feed for each of the modules. The RSS feeds are cached for three hours using SMF's built-in cache handling to reduce server processing time.

This mod does not use any external RSS modules, using instead PHP's file_get_contents() function. This makes the module very small and speedy.

This module may be added very easily to any custom template by simply adding the following code in you index.template.php file.

// <!--Begin Free Content Mod-->

if (!empty($modSettings['FreeContentMaster']))
{
require_once($sourcedir . '/FreeContent.php');
$free_number = free_quote_select();

if ($free_number <> '')
{
echo '<div style="float:right">

'.$free_number.'

</div>';
}}

// <!--End Free Content Mod-->



Add this line wherever the theme loads the css files:

echo '
<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/freecontent.css" />';


and finally add

$sourcedir,

whereever you find this line:

   global $context;

make it look like

   global $sourcedir, $context;


And that's it!

Finally to edit the css file, it it located in the default theme/css as freecontent.css


----------------------------------------------------------

As this mod becomes more popular, I plan to add additional support for alternate themes and a version for SMF 1.1.8.

----------------------------------------------------------

I am available to install this or other mods on your SMF forum. Please PM me for a fee quote.
Title: Re: Free Content
Post by: Afro on April 28, 2009, 05:55:07 AM
that would be good for 1.1.8. i will be waiting
Title: Re: Free Content
Post by: tfs on April 28, 2009, 07:55:13 PM
I get an error on install on

*    2.    Execute Modification    ./Sources/Load.php    Test failed
      1.    Add After    ./Sources/Load.php    Test failed

Find:
  if ($set == 'normal') { $select_columns = ' IFNULL(lo.log_time, 0) AS is_online, IFNULL(a.id_attach, 0) AS id_attach, a.filename, a.attachment_type, 

Add After:

  mem.free_bible, mem.free_quote, mem.free_word, mem.free_random,

But as far as I can tell my Load.php file is stock at that point.  It seems like it's not finding what it's looking for based on a missing/extra carriage return, space or a tab.  Is it just me or does anyone else get that?
Title: Re: Free Content
Post by: Keith Tysinger on April 28, 2009, 08:32:40 PM
I tweaked the search and replace feature. Hopefully we will never see that error again.

Quote from: tfs on April 28, 2009, 07:55:13 PM
I get an error on install on

*    2.    Execute Modification    ./Sources/Load.php    Test failed
      1.    Add After    ./Sources/Load.php    Test failed

Find:
  if ($set == 'normal') { $select_columns = ' IFNULL(lo.log_time, 0) AS is_online, IFNULL(a.id_attach, 0) AS id_attach, a.filename, a.attachment_type, 

Add After:

  mem.free_bible, mem.free_quote, mem.free_word, mem.free_random,

But as far as I can tell my Load.php file is stock at that point.  It seems like it's not finding what it's looking for based on a missing/extra carriage return, space or a tab.  Is it just me or does anyone else get that?
Title: Re: Free Content
Post by: tfs on April 28, 2009, 08:53:18 PM
I got it installed, but now my error log gets two entries with every page refresh...


at 04:46:23 PM
http://www.xxxx.com/forum/index.php?action=admin;area=logs;sa=errorlog;desc;filter=error_type;value=general
2: file_get_contents(http://feeds2.feedburner.com/quotationspage/qotd) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: no suitable wrapper could be found
File: /path/path/path/path/path/forum/Sources/FreeContent.php
Line: 63



   
at 04:46:23 PM
http://www.xxxx.com/forum/index.php?action=admin;area=logs;sa=errorlog;desc;filter=error_type;value=general
2: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: URL file-access is disabled in the server configuration
File: /path/path/path/path/path/forum/Sources/FreeContent.php
Line: 63
Title: Re: Free Content
Post by: tfs on April 28, 2009, 08:58:48 PM
Trying to uninstall got me this...

Fatal error: require_once() [function.require]: Failed opening required '/path/path/path/path/forum/Sources/FreeContent.php' (include_path='.:/usr/lib/php5') in /path/path/path/path/forum/Sources/Load.php(1973) : eval()'d code on line 220
Title: Re: Free Content
Post by: Keith Tysinger on April 29, 2009, 04:27:52 AM
I've seen this one too. If you turn the mod "off" before uninstalling, it doesn't generate an error.

The uninstall works either way. I've added additional notes for the uninstall procedure so that others will know to turn the mod off before uninstalling.

The other error is one that I antisipated. Some servers will not allow the use of file_get_contents() -- which reads the RSS feed. Initially I was using an external RSS library but the one additional file was over 300K.

So I went with the smaller file size as suggested by the SMF Mod approval team. The downside is that this mod will not work on every server. I have my old (unapproved) MOD which does not use the file_get_contents if anyone wants it. It uses the simplepie RSS library.


Quote from: tfs on April 28, 2009, 08:58:48 PM
Trying to uninstall got me this...

Fatal error: require_once() [function.require]: Failed opening required '/path/path/path/path/forum/Sources/FreeContent.php' (include_path='.:/usr/lib/php5') in /path/path/path/path/forum/Sources/Load.php(1973) : eval()'d code on line 220
Title: Re: Free Content
Post by: tfs on April 29, 2009, 10:52:51 AM
Quote from: Keith Tysinger on April 29, 2009, 04:27:52 AMI have my old (unapproved) MOD which does not use the file_get_contents if anyone wants it. It uses the simplepie RSS library.

What I would really like is a different mode where you pull the quotes from a data file that exists somewhere on my server.  I do like the look of what you have, at least from the pictures you posted of it, but I'd like to provide the quotes myself.
Title: Re: Free Content
Post by: Keith Tysinger on April 29, 2009, 11:38:42 AM
That is exactly what I wanted to do, but I could not find the content. If you know where I can get a lot of good quotes I would consider adapting it for database use. I would like to have about 200 quotes at a minimum. I was surprised that I couldn't find them available. I would love to have all of Einstein's quotes but I couldn't even find them.

Quote from: tfs on April 29, 2009, 10:52:51 AM
Quote from: Keith Tysinger on April 29, 2009, 04:27:52 AMI have my old (unapproved) MOD which does not use the file_get_contents if anyone wants it. It uses the simplepie RSS library.

What I would really like is a different mode where you pull the quotes from a data file that exists somewhere on my server.  I do like the look of what you have, at least from the pictures you posted of it, but I'd like to provide the quotes myself.
Title: Re: Free Content
Post by: tfs on August 08, 2009, 01:48:11 AM
Anything ever happen here about using a local data file?
Title: Re: Free Content
Post by: Keith Tysinger on March 15, 2010, 03:51:50 AM
SMF 2.0 RC3 is now supported, along with very minor bug fixes. Enjoy!

Check out my demo site, www.MadCoder.biz/forum
Title: Re: Free Content
Post by: Keith Tysinger on March 15, 2010, 06:33:09 AM
It's still a great idea! I simply haven't had the time to develop it. I guess I am satisfied with the RSS feeds for now.

Quote from: tfs on August 08, 2009, 01:48:11 AM
Anything ever happen here about using a local data file?
Title: Re: Free Content
Post by: tfs on March 15, 2010, 02:50:19 PM
Quote from: Keith Tysinger on March 15, 2010, 06:33:09 AM
It's still a great idea! I simply haven't had the time to develop it. I guess I am satisfied with the RSS feeds for now.

OK... just checking.  I sent you a couple of big text files at one time, hoping to entice you to add the ability to pull from them.  My "shared" server package does not have the ability to use this as it is now.
Title: Re: Free Content
Post by: luuuciano on April 10, 2010, 10:25:16 AM
+1 to local file... :)

in some sites I have used a file with phrases separated by thins like %%

quote1
%%
quote2
%%
etc

currently I have added Notices, to show random lines in the header... lol
(the bruteforce way)
Title: Re: Free Content
Post by: KensonPlays on July 30, 2010, 07:40:09 PM
Can i unselect the bible verses?
Or select a different area to display them? (NWT)
Title: Re: Free Content
Post by: Biology Forums on February 28, 2011, 04:34:05 PM
Hi,

I have a wikimedia with many different articles. Would it be possible to have one of those article be displayed as "the article of the day?" If so, how would I do it?
Title: Re: Free Content
Post by: milo01 on February 28, 2011, 04:41:29 PM
Hi...i have a blank page problem with the shoutBox.

the shout box are in my forum page (SMF 2.0 RC3) and i installed TinyPortal 1.0 RC1 mod...

i am on windows system..i created .htaccess on mySite/forum folder with this line:

RewriteEngine on
RewriteRule ^chat/?$ ./chatx/index.php [L,QSA]

but it's always white....can you hel me please?!

Bye Bye and sorry for my bad english...

Title: Re: Free Content
Post by: Kimmie on September 25, 2014, 11:00:17 PM
Has anyone tried this on 2.0.8?