Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Plugin | Random Content Display
#1
Simple Random Plugin 1.2
This plugin allows the display of randomised content within your template. Add's a 'Random Content' tab to the admin section for you to enter your random content whatever it may be. This plugin should allow for almost anything including <img> tags, flash files essentially anything although it was made for text.

Update 1.2:
- Menu item now activates when on the random page (yay)

Update 1.1:
- Removed 'sample display code from creation section
- Fixed bug in error checking duing meta file creation

Usage:
1. Extract folder and place all files into /plugin/ folder.
2. Refresh page to install new admin page, and copy sample xml files into data/other
3. Go to 'settings' page to enter the number of random quotes you would like to have as a maximum (will be made redundant in version 2)
4. Go to "Random Content' and enter the title and description of your content. Just ignore one of the fields if you only want a single piece of content displaying as it will print whatever you enter.
5. Place the following code into your template:

Code:
<?php
if(function_exists("simple_random_display")) {
  simple_random_display("2");
}
?>

Option: The '2' allows you select the order of the comments display.
1: title, then description
2: description, then title

-- I may expand on option displays in the future. (including only showing one)

-----------------------------------------------------------------------------------------------
Please note i do not guarentee 100% perfection, but please do let me know if theres any obvious bugs and i'll see what i can do.
Nothing is too difficult... anything is possible.
'But you tried, and you failed.. the important thing? never try'
Reply
#2
Hey,

Plugin works and looks great..

Couple of small little things..

o - Line 57 outputting some of your demo text??

o - Small problem with the saving settings option.

line 121 needs to be changed to
Code:
if($_POST['numberoffields'] != "") {

o - Also tabs don't work correctly, not properly highlighted when on the admin panel.
Preference should be to use the sidebars as the highlight code is built into the plugin system.

Mike...
My Github Repos: Github
Website: DigiMute
Reply
#3
Hey thanks for trying it out and leaving feedback!

Demo text huh lol doesn't shock me I'll have a look and get it fixed up and will check the other line you mentioned.

I noticed the admin tab so yeah I'll fix that up as it just losses something without it. I just hoped noone else would lol

the last part confused me though. Could you elaborate please?
Nothing is too difficult... anything is possible.
'But you tried, and you failed.. the important thing? never try'
Reply
#4
I want to do something similiar to what you did with your plugin. Install a new tab.. but I see that you pretty much created a new php file inside of the admin.

I just wanted to ask, how correct is this? I mean, for maintenance reasons (uninstall + upgrades). Users will not know that there is a new file created automatically for them in the admin folder.

I'm not questioning your practice.. instead I'm looking for a better solution to this.

You see, right now, for example.. my gallery plugin creates a new right menu item in the plugin page, this has a link to load.php that loads the content of my function into the same tab. This way I don't have to create a new file and include it in the admin.

So my question is more to Chris and Mike.. shouldn't the creation of the a tab element work similar to the creation of a right menu item? Give us like an empty admin canvas page.. that we can add content and right menu items.

This way we dont have to mess around with the inclusion of header and footer and trying to recreate the admin page.
- Julian

My GetSimple Plugins: Simple Image Gallery | TweetMeme reTweet Button
Reply
#5
Is it posible to use different styles on Title and Description in the output? I was thinking of using it as a random quote plugin, where the quote itself should be written in italic, and the author without italic.

Like this:
"It's hard to beat somebody when they don't give up" - Babe Ruth
Reply
#6
Lines 81, 82, 85 and 86 of the plugin file (simple-random.php) tell the page what to display. As an example, if we take the quote as the title (because it’s unique) and the author as the description we would want to display title first. This means lines 85 and 86 are the ones we’ll be using.

Code:
echo htmlspecialchars_decode((string)$data_edit->content[$random_number]->contenttitle[0]);
      echo htmlspecialchars_decode((string)$data_edit->content[$random_number]->contentinformation[0]);
Let’s put some quotation marks around the quote and a dash before the author:
Code:
echo "“".htmlspecialchars_decode((string)$data_edit->content[$random_number]->contenttitle[0])."”";
      echo " - ".htmlspecialchars_decode((string)$data_edit->content[$random_number]->contentinformation[0]);
The same goes for italics:
Code:
echo "“<i>".htmlspecialchars_decode((string)$data_edit->content[$random_number]->contenttitle[0])."</i>”";
      echo " - ".htmlspecialchars_decode((string)$data_edit->content[$random_number]->contentinformation[0]);
Now if you have written It’s hard to beat somebody when they don’t give up. as the title of some random content, and gave it a description Babe Ruth, simple_random_display() will output the following HTML:
Code:
“<i>It’s hard to beat somebody when they don’t give up.</i>” - Babe Ruth

Hope you understood, you can add any HTML you want!
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#7
That was a great answer for a newbie like myself, thank you very much! The quotation marks was displayed with some errors in my browser though, but got it fixed by changing them to the html tag for it: &quot
Reply
#8
Razzia Wrote:The quotation marks was displayed with some errors in my browser though
You can’t put straight quotation marks (") in PHP when you are enclosing the string with them as well. That’s why I was using the curly ones (“ and ” ≠ "). Just so you know for possible future edits ;-)
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#9
Zegnåt Wrote:
Razzia Wrote:The quotation marks was displayed with some errors in my browser though
You can’t put straight quotation marks (") in PHP when you are enclosing the string with them as well. That’s why I was using the curly ones (“ and ” ≠ "). Just so you know for possible future edits ;-)

Hmm, I just copy pasted from your example into notepad++, and that didn't work. Anyway problem solved :-)

Thank you for all your help
Reply
#10
Can this plug in be used to include ads and banners to your site?

If so, how do I include an image?

Thanks.

homershines
Reply
#11
I often use this plugin, the constant need to display a certain number of characters, it would be nice to attach here jquery.limit-1.2.js
Reply
#12
This plugin doesn't work with GetSimple 3.0. Any idea when can we get an update?
Reply
#13
Number of random text can not edit in version 3.1B r525
urgent help
Reply
#14
He and version 3 does not work
Reply
#15
someone please repair the this plugin please
Reply
#16
@Oleg06

This plugin (like SimpleAnalytics, I believe) stopped working after GS 2.03 because a plugin hook was removed in 3.0.

Here's a quick fix for GS 3.0.

Edit admin/settings.php, line 140 or so, after this line:
Code:
include(GSLANGPATH.$LANG.'.php');

insert this:

Code:
exec_action('settings-cpsettings');

(In GS 3.1 beta it would be line 145 or so.)

Not sure if it might have some problem... I've done a quick test and seems to work.
Reply
#17
Was unaware that the changing version had broken this plugin and seemingly simple analytics also. Will look into how to update for version 3+
Nothing is too difficult... anything is possible.
'But you tried, and you failed.. the important thing? never try'
Reply
#18
Thanks Carlos, work
I hope the plugin fix
Reply




Users browsing this thread: 1 Guest(s)