• Welcome to Simple Machines Community Forum. Please login or sign up.
December 06, 2021, 04:35:35 PM

News:

SMF 2.0.18 has been released! Please update. Read more.


Free Content

Started by Keith Tysinger, April 27, 2009, 10:57:58 PM

Previous topic - Next topic

Keith Tysinger

April 27, 2009, 10:57:58 PM Last Edit: March 15, 2010, 05:18:28 AM by Keith Tysinger
Link to Mod

Free Content
Version: 1.2
Mod by J. Keith Tysinger


Demo: 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:
Keith.Tysinger@gmail.com



If you liked this mod, please check out my other one: Buy me a Drink


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
Contact me for all of your website design needs.

Keith Tysinger

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.
Contact me for all of your website design needs.

Afro

that would be good for 1.1.8. i will be waiting

tfs

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?
A good tree cannot bring forth evil fruit, neither can an evil tree bring forth good fruit.

Keith Tysinger

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?
Contact me for all of your website design needs.

tfs

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
A good tree cannot bring forth evil fruit, neither can an evil tree bring forth good fruit.

tfs

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
A good tree cannot bring forth evil fruit, neither can an evil tree bring forth good fruit.

Keith Tysinger

April 29, 2009, 04:27:52 AM #7 Last Edit: April 29, 2009, 07:50:46 AM by Keith Tysinger
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
Contact me for all of your website design needs.

tfs

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.
A good tree cannot bring forth evil fruit, neither can an evil tree bring forth good fruit.

Keith Tysinger

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.
Contact me for all of your website design needs.

tfs

Anything ever happen here about using a local data file?
A good tree cannot bring forth evil fruit, neither can an evil tree bring forth good fruit.

Keith Tysinger

SMF 2.0 RC3 is now supported, along with very minor bug fixes. Enjoy!

Check out my demo site, www.MadCoder.biz/forum
Contact me for all of your website design needs.

Keith Tysinger

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?
Contact me for all of your website design needs.

tfs

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.
A good tree cannot bring forth evil fruit, neither can an evil tree bring forth good fruit.

luuuciano

+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)
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

KensonPlays

Can i unselect the bible verses?
Or select a different area to display them? (NWT)

Biology Forums

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?

milo01

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...


Kimmie

Has anyone tried this on 2.0.8?

Advertisement: