Scoop -- the swiss army chainsaw of content management
Front Page · Everything · News · Code · Help! · Wishlist · Project · Scoop Sites · Dev Notes · Latest CVS changes · Development Activities
HOWTO: create a new opcode without writing any code New Code
By K5_eries , Section Code []
Posted on Sat Dec 30, 2000 at 12:00:00 PM PST
The title doesn't sound too exciting, but I think this is a pretty useful technique. I am writing this little tutorial in the hopes that it will encourage more people who dont' necessarily have that much coding experience to hack Scoop. Thanks to a combination of new features, especially boxes and templates, it is really easy to add all kinds of new functionality to Scoop from within the web-admin interface. I'm going to walk through the steps requried to add an online help system, which is something I've wanted to do for a while, anyway.

Goal
Our goal in this tutorial is to add the following feature to Scoop. You can type, anwhere and on any page, something like this into your Scoop blocks:

|BOX,help_link_box,foobar,About Foobar|
(although later we'll discuss how to make |HELP,x,y| an alias for this)

This will create a link that, when clicked, creates a new popup window with help about the topic 'foobar' - the content of which is stored in a block called 'help-foobar'. Although I'm not going to get into the details here, this can be made real pretty with all kinds of fancy Javascript tricks too. I'm going to keep the code in this tutorial Javascript-free, so as not to complicate the issue.

This is going to require a few changes to the Scoop code. Hopefully, you've got the latest version from CVS, although this should all work on any 0.6-based release or prerelease. Also, I'm hoping that the two places that do require changes to the code will eventually be changed so that the changes can be accomplished from the Vars menu instead. I'll have to talk to Rusty about that.

Creating the link
Anyway, back on topic. The first thing we need to do is create a Box that will print out the link when called. This box will not have any HTML associated with it, so we need to create an HTML box template called "raw_box" - which looks like this one line:


|CONTENT|


The code for the box, with boxid help_link_box, looks like this:

#First, get the two arguments, x and y. In our example, $target == "foobar" and 
# $label == "What's Foobar?"
my $target = shift @ARGS;
my $label = shift @ARGS;

#This should eventually become a block, but for now just print it out raw
my $content = qq{ <a href="|rootdir|/?op=help;helpid=$target" target=_help>$label</a> };

return { content => $content };

Be sure to associate this box with the raw_box template from the Templates SELECT box in the Boxes control panel.

Creating the "help" opcode
This is one of two places where you'll need to edit the scoop codebase, although like I said I hope that one day we'll get this controlled through a var. The file lib/Scoop/OpTemplates.pm controls which opcodes are shown in the "Templates" control panel (under Admin Tools). Just add "help" to the list of values. Restart Apache, and we're good to go.

Everything else from this point on does not require any changes to the scoop codebase, and can be done through the web interface. We need to create a template for the help display page. Again, this will be another one-line block, call it help_template:


|BOX,help_display_box|


In the Templates control panel, associate the "help" opcode with the "help_template" template.

The help_display_box will be required to provide all of the HTML necessary to make the page look good, so let's give it a nice block to do this in. Call it, for simplicity, help_display_box, and have it look something like this:


<HTML>
<HEAD>
<TITLE>|TITLE|</TITLE>
</HEAD>
<BODY>
<h1>|TITLE|</h1>
<p>
|CONTENT|
</BODY>
</HTML>

Now, it's time to create the help_display_box box. Be sure to associate it with the box template of the same name (it should show up in the "templates" SELECT box in the Boxes control panel). Here's the code for the help_display_box. It could use some additional error checking, etc. but let's keep it short for now:


#get the CGI paramters generated by help_link_box
my $target = $S->{CGI}->param( 'helpid' );

my $title = "Help about $target";
#get the content from the appropriately-named block
my $content = $S->{UI}->{BLOCKS}->{$target} || "Error: no content found for $target";

return { title => $title, content => $content };

Creating the help
That's it for the help system. All that remains is to actually create some help. This is accomplished using the Blocks system. For help about topic foobar, just create a block called "help-foobar" and put whatever HTML-formatted help in it that you would like. This block will automatically get loaded at the right time by the system we just created.

Advanced Topics
There's one more thing that would be nice, and that is to allow using the syntax |HELP,foobar,About Foobar| instead of the clunky |BOX,help_link_box,foobar,About Foobar|. Turns out, this is not so difficult. It requires two changes to the Scoop code, and here they are.

First, in lib/Scoop.pm look for a block like the following (it's line 425 for me):


      my $special_keys = {
          "BOX" => 'Scoop::box_magic',
          "URL" => 'Scoop::make_url',
          "A"   => 'Scoop::make_anchor'
      };

Add another mapping to this list: "HELP" => 'Scoop::make_help'.

Next, open up lib/Scoop/Utility.pm and add a function called make_help. It should look like this:


sub make_help 
{
    my $S = shift;
    my @ARGS = @_;
    
    return $S->box_magic( @ARGS );
}

Restart Apache, and you're done.

Well, folks, that's it for now. Sorry if any parts of this are confusing. This is a first draft, and since I am not near my Scoop install, the code is untested. I'll hopefully get some patches for the current CVS code that are a bit more elaborate than what's described here soon, if there is interest. So let me know if this is something you might find useful.

As always, feedback/questions/criticisms are more than welcome.

< Permanent Discussion Boards | Author deletion of stories >

Menu
· create account
· faq
· search
· report bugs
· Scoop Administrators Guide
· Scoop Box Exchange

Login
Make a new account
Username:
Password:

Related Links
· Scoop
· More on New Code
· Also by K5_eries

Story Views
  225 Scoop users have viewed this story.

Display: Sort:
HOWTO: create a new opcode without writing any code | 72 comments (71 topical, 0 hidden)
first corrections (4.00 / 2) (#2)
by K5_eries on Sat Dec 30, 2000 at 10:03:20 PM PST

Well, I'm near my Scoop install now, and I'm already finding bugs with the code outlined above. Here are my first set of corrections:
  • In several places, I erroneously used ALL-CAPS block names, like |CONTENT| and |TITLE| - these should be replaced with all-lower-case versions, like |content| and |title|.
  • The key line in the help_display_box box should read:
    my $content = $S->{UI}->{BLOCKS}->{"help-".$target} \|\| "Error: no content found for $target";
  • make_help (in Utility.pm) should actually read like this:
    
    sub make_help 
       {
           my $S = shift;
           my @ARGS = @_;
           
           return $S->box_magic( 'help_link_box', @ARGS );
       }
    
    
That should just about do it. Enjoy.



great work around (none / 0) (#3)
by vegaskid on Tue Mar 03, 2009 at 08:25:02 PM PST

Wow what a great work around code. I've been trying to implement a new opcode for my philippines board website. This is the perfect workaround for my lazy bum. Thanks in advance k5



noti (none / 0) (#4)
by bluejade on Wed Sep 28, 2011 at 08:46:15 PM PST

l'attention de tous les enseignants qui réfléchissent à ce qu'ils FONT en cours. A enseigner dans les IUFM. Le site est bien fichu, polyglotte, et cette nouvelle revue promet ! oil press



Reply (none / 0) (#5)
by bynes69 on Mon Oct 24, 2011 at 06:13:34 AM PST

its good to see this information in your post, i was looking the same but there was not any proper resource. Research Paper Help Term Paper Help Essay Help



Reply (none / 0) (#6)
by bynes69 on Mon Oct 24, 2011 at 06:14:10 AM PST

Amazing one, i appreciate this work.... Thesis Help Dissertation Help



winen (none / 0) (#7)
by bluejade on Wed Oct 26, 2011 at 10:34:18 PM PST

Let me start by saying nice post. Im not sure if it has been talked about, but when using Chrome I can never get the entire site to load without refreshing many times. oil press



server (none / 0) (#8)
by evasmith8812 on Thu Nov 10, 2011 at 11:44:03 AM PST

Thanks for providing a way to do this without having to write code. Sometimes it is much better to be able to follow a tutorial like this that you have to learn computer language. I'd be interested to know if you guys use a dedicated server or to use a shared server? I'm not sure what the best practice is.



Re: (none / 0) (#9)
by rrgan12 on Fri Nov 25, 2011 at 05:39:13 PM PST

This is a great post it was very informative. I look forward in reading more of your work. Also, I made sure to bookmark your website so I can come back later. I enjoyed every moment of reading it.
-budget van insurance



Great! (none / 0) (#10)
by apollosan11 on Thu Dec 15, 2011 at 05:44:01 PM PST

this is such a great thing to know "This will create a link that, when clicked, creates a new popup window with help about the topic 'foobar' - the content of which is stored in a block called 'help-foobar'. Although I'm not going to get into the details here, this can be made real pretty with all kinds of fancy Javascript tricks too. I'm going to keep the code in this tutorial Javascript-free, so as not to complicate the issue" surely more developments will be coming.... background check



nice post (none / 0) (#11)
by smithhogg on Thu Dec 29, 2011 at 03:55:35 AM PST

Always prefer to read the quality content and this thing I found in your post. Thanks for sharing. Essay writing | university essays



Wow (none / 0) (#12)
by dzemomona12 on Fri Dec 30, 2011 at 07:11:31 AM PST

World of Warcraft Guides is a great site about World of Warcraft farming and leveling up the professions. The best WoW Leveling Guide is without a doubt Zygor Guides. Herbalism Guide is best combined with Alchemy Guide, because you get all the materials. If you want to try this Mining Guide, you should consider Blacksmithing Guide or Jewelcrafting Guide. Just keep in mind that even with professions like First Aid Guide, Fishing Guide, Cooking Guide or Archaeology Guide, you can earn a lot of gold. If you play hunter, I recommend to look this Skinning Guide and as a second profession take Leatherworking Guide. For PvP players in WoW the best profession is Engineering Guide and Inscription Guide. If you play PvE and you have a cloth character like Priest, Mage, Warlock, the best profession is Enchanting Guide, combined with Tailoring Guide



Advanced Topic (none / 0) (#13)
by Juniorul on Tue Jan 03, 2012 at 08:05:47 AM PST

This is one of two places where you'll need to edit the scoop codebase, although like I said I hope that one day we'll get this controlled through a var.public records search



thanks (none / 0) (#14)
by kathybates on Tue Jan 03, 2012 at 10:43:49 AM PST

You have just made my life much simpler. During stressful period of ovulation symptoms I can hardly think about coding for my website. This will make things so much easier for me. Cheers!



Code (none / 0) (#15)
by colinstead on Tue Jan 03, 2012 at 12:13:44 PM PST

I've just read this and was wondering probably how out of date it all is now!! teeth whitening thanks anyway



Well said (none / 0) (#17)
by Tutaj on Tue Jan 03, 2012 at 01:30:44 PM PST

Well said thank you. Great stuff You did an incredible job here. india australia live streaming



opcode without code (none / 0) (#18)
by colinstead on Wed Jan 04, 2012 at 05:38:32 AM PST

Great thanks Fleshlights



insurance rates (none / 0) (#19)
by austinturley on Wed Jan 04, 2012 at 08:43:38 PM PST

Great story! I definitely feel that you get out of life what you put into it, and only putting in expecting to get out is not the best way to get lasting success, fulfillment, happiness etc. insurance rates.



insurance rates (none / 0) (#20)
by austinturley on Wed Jan 04, 2012 at 08:45:47 PM PST

Great story! I definitely feel that you get out of life what you put into it, and only putting in expecting to get out is not the best way to get lasting success, fulfillment, happiness etc.insurance rates.



insurance rates (none / 0) (#21)
by austinturley on Wed Jan 04, 2012 at 08:47:20 PM PST

Great story! I definitely feel that you get out of life what you put into it, and only putting in expecting to get out is not the best way to get lasting success, fulfillment, happiness etc..insurance rates



low rate insurance (none / 0) (#22)
by austinturley on Wed Jan 04, 2012 at 08:48:25 PM PST

trust this is a nice blog. Want to see fresh content next occasion. Many thanks for sharing this post with us. Stay the best.low rate insurance.



insurance rates in Texas (none / 0) (#23)
by austinturley on Wed Jan 04, 2012 at 08:51:40 PM PST

Thank you for the extremely impressive article. It has great detail that are easy to understand and it also has great tips. I can't wait to read more of your blogs.interesting to read..insurance rates in Texas



Secondary Market Annuity (none / 0) (#24)
by mrazaabbas on Thu Jan 05, 2012 at 11:44:41 AM PST

This is so amazing and nice blog that i have bookmarked and shared its link to my Facebook wall as well. Secondary Market Annuity



Auperb (none / 0) (#25)
by burl conde on Sat Jan 07, 2012 at 02:38:20 AM PST

I've read through a number of the articles in your website , and I love the way you blog. I included it to my favorites blog site list and will also be checking quickly. stop snoring



newbies (none / 0) (#26)
by jeavon harp on Sun Jan 08, 2012 at 05:59:08 AM PST

I am new with this topic but I am willing to understand and learn this stuff. I am very thankful for the knowledge and informations you shared. Next time I'll participate with the discussion at a higher level. But for now I'd like to post a quick message for I am trying to feel my way around.
http://www.breastactivesguide.com/



WOW (none / 0) (#27)
by howtotintwindows on Tue Jan 10, 2012 at 07:47:06 PM PST

OMG. Is that for real? I can't believe it. Car Window Tinting



weldi (none / 0) (#28)
by bluejade on Tue Jan 10, 2012 at 10:42:06 PM PST

Your concepts were easy to understand that I wondered why I never looked at it before. Glad to know that there's an individual out there that definitely understands what he's discussing. Turkish Apricots



weld (none / 0) (#29)
by bluejade on Tue Jan 17, 2012 at 01:23:50 AM PST

The employment scene seems to get more brutal all the time. Here too employers have the law on their side and know it! Apple Dice



It proved (none / 0) (#30)
by superking on Tue Jan 17, 2012 at 05:52:52 AM PST

It proved to be Very helpful to me and I am sure to all the commentators here! payday UK



The information (none / 0) (#31)
by superking on Wed Jan 18, 2012 at 02:16:26 AM PST

The information you have posted is very useful. The sites you have referred was good. Thanks for sharing. payday advance online



Bingo Jackpot (none / 0) (#33)
by luka4gel on Wed Jan 18, 2012 at 07:52:52 PM PST

I always get too thrilled in playing bingo especially when I'm with my pals. We check the website regularly just to know about the Bingo Jackpot schedule. We are really looking forward in winning. Even though we know you have to be fortunate enough to win the jackpot, but we also do it for fun anyway.



I read it too but... (none / 0) (#35)
by Juniorul on Sun Jan 22, 2012 at 03:01:47 PM PST

Working on the give topic is really a difficult task but your this tutorial made it easy for me to handle it without any problem. If anyone seeking information then this blog is the best place for him as it has quality content for your required information. Thanks for sharing. Resting Metabolic Rate Calculator



Andrew Reynolds (none / 0) (#37)
by arco67wil on Tue Jan 24, 2012 at 10:48:09 PM PST

I'm not really usually driven by informative blog posts, yet yours truly made me start thinking about your points of views. You have presented useful and strong thoughts that are sensible and engaging. I personally care to talk about Andrew Reynolds. And so I am conscious of the effort and hard work it will require forming an informative article like this. Thanks for spreading your positive work.



Thanks (none / 0) (#39)
by dmtaylor247 on Sat Jan 28, 2012 at 10:37:52 AM PST

Thanks for the help it's really appreciated! Watch Free Movies Online



There's an issue with the site in internet (none / 0) (#41)
by alat kesehatan on Sun Jan 29, 2012 at 08:21:41 AM PST

Hey. Neat post. There's an issue with the site in internet , and you may want to test this... The browser is the topic leader and a good part of component to other folks people will leave pass over your great writing due to this problem. alat kesehatan | medical equipment supplies



Lifesaver (none / 0) (#43)
by Laura898 on Mon Jan 30, 2012 at 10:10:56 AM PST

Thanks guys, this was wrecking my head for ages :) cheap weed seeds | pot seeds | cheap marijuana seeds | cannabis seeds for sale. | seed bank reviews



Very helpful (none / 0) (#44)
by Laura898 on Mon Jan 30, 2012 at 10:13:21 AM PST

This works a treat for my site, thanks for sharing guys :) how to train a puppy | puppy biting | puppy crying | puppy whining | puppy growling | puppy separation anxiety | crate training puppies | puppy training tips | puppy aggression | weaning puppies | how to leash train a puppy | puppy toilet training | house training a puppy



Great article (none / 0) (#45)
by kalwi87 on Tue Jan 31, 2012 at 05:57:01 AM PST

Thanks for great article ! odzyskiwanie danych warszawa nowoczesne firany Kołobrzeg kwatery Okna Drewniane Fotografia eventowa warszawa



Scoop is Great (none / 0) (#47)
by harry on Thu Feb 02, 2012 at 02:19:49 AM PST

Ways or the ideas given by the Scoop for coding in a very simple way is unimagined. I always searches about the easiest ways of coding and Scoop gave the best one.



Great article (none / 0) (#48)
by kalwi87 on Thu Feb 02, 2012 at 07:21:16 AM PST

That's it for the help system. All that remains is to actually create some help. This is accomplished using the Blocks system. wakacje For help about topic foobar, just create a block called "help-foobar" and put whatever HTML-formatted help in it that you would like. This block will automatically get loaded at the right time by the system we just created.



I like your web-site (none / 0) (#51)
by axemgm on Fri Feb 03, 2012 at 03:24:54 PM PST

Of course I like your web-site, however you have to} take a look at the spelling on quite a few of your posts. Many of them are rife with spelling issues and I find it very bothersome to inform you. Nevertheless I'll surely come back again! cheap backlinks



Nice (none / 0) (#52)
by spr31 on Fri Feb 03, 2012 at 11:45:55 PM PST

In order to execute an SQL statement, the SQLite library first parses the SQL, analyzes the statement, then generates a short program to execute the statement. The program is generated for a "virtual machine" implemented by the SQLite library. sprei | sprei murah



thanks (none / 0) (#53)
by andalusy on Sat Feb 04, 2012 at 11:15:49 AM PST

Good posting, im subscribing to your rss. Thanks for sharing a very informative article. Many thanks once more افلام



good (none / 0) (#54)
by andalusy on Sat Feb 04, 2012 at 11:17:13 AM PST

افلام اجنبية|افلام عربية|افلام عربى|مشاهدة افلام عربية|مشاهدة افلام مباشرة|افلام اجنبي|مشاهدة افلام|مشاهدة افلام اجنبية|aflam|تحميل افلام|افلام|افلام مشاهدة مباشرة|افلام مباشرة|مشاهدة افلام بدون تحميل|مشاهدة افلام اون لاين|افلام اجنبية اون لاين|افلام عربية اون لاين|افلام اجنبي اون لاين|مشاهدة افلام اجنبية اون لاين|مشاهدة افلام عربي اون لاين|مشاهدة افلام اجنبى اون لاين|افلام اون لاين بدون تحميل



Good... (none / 0) (#55)
by ferrara9920 on Mon Feb 06, 2012 at 11:55:07 PM PST

Many advanced assemblers offer additional mechanisms to facilitate program development, control the assembly process. In particular, most modern assemblers include. Manhole



thanks for the post (none / 0) (#59)
by snesxp on Wed Feb 08, 2012 at 04:59:48 PM PST

nice opcode article, thanks for share with us sex shop hipertrofia medicina do esporte sexy shop



great tips I'll try that (none / 0) (#60)
by carcoupons4u on Wed Feb 08, 2012 at 05:47:54 PM PST

Thank you for a very informative blog. Where else could I get that kind of information written in such an ideal approach? I've a undertaking that I am just now operating on, and I have been on the look out for such info.rental car coupons|advantage car rental coupons



Nice... (none / 0) (#61)
by delalex35 on Thu Feb 09, 2012 at 12:15:47 AM PST

In a previous issue of this journal I described how to "bootstrap" yourself into a new processor, with a simple debug monitor. Melibahenling



create a new opcode without writing any code (none / 0) (#62)
by alfiealexander on Thu Feb 09, 2012 at 04:35:00 AM PST

I see you're using Local Cert. Can you connect without it? If so, does connecting without Local Cert help? Lafer Recliner



The Opcode package contains functions (none / 0) (#63)
by williamlane on Thu Feb 09, 2012 at 08:03:56 AM PST

The Opcode package contains functions for manipulating operator names tags and sets. All are available for export by the package. n a scalar context opcodes returns the number of opcodes in this version of perl (around 350 for perl-5.7.0). Internet Marketing Consultant



Workshop equipment (none / 0) (#64)
by toni64kar on Thu Feb 09, 2012 at 07:54:44 PM PST

I'm not normally energized by educational articles, yet your article really made me give some thought to your sentiments. You have provided important and strong ideas that are logical and engaging. I professionally care to write about Workshop equipment. So I am conscious of the effort it takes to make an educational write-up like this. Thanks for revealing your effective work.



Nice bro (none / 0) (#65)
by TheGateKeeper on Fri Feb 10, 2012 at 09:03:52 AM PST

Amazingly nice blog mate, makes me think of me of Self Defense Laws, or maybe heavy bag workout.thanks from stretches for hamstring. Do us a favor and keep posting and never take this website down. Also, check out Muay Thai Camps in Thailand.



my personal opinion (none / 0) (#67)
by harganotebook on Fri Feb 17, 2012 at 03:31:45 PM PST

hi all website's member, i like such video and article presented in this website. I am the website owner of movies website from Indonesia. You could contact me in my website ceritafilm.com.Nice to meet you all guys Ultrabook notebook tipis harga murah terbaik | harga notebook



nice (none / 0) (#69)
by kabila on Sun Feb 19, 2012 at 11:41:27 AM PST

This is accomplished using the Blocks system. For help about topic foobar, just create a block called "help-foobar" and put whatever HTML-formatted help in it that you would likeGainey Ranch homes for sale



getien (none / 0) (#71)
by bluejade on Mon Feb 20, 2012 at 09:34:49 PM PST

My thought is that if things were done so well at your last job, why did you leave? spring cone crusher



Best cheap minisite graphic template design servic (none / 0) (#72)
by cheapminisitedesign on Tue Feb 21, 2012 at 02:09:50 AM PST

If you want to create a mini website or minisite. maybe this cheap minisite graphic tempalte design website will help you alot. Cheap ministe site design always get you achieve your goal faster than you expected. That's the reason why you should create suitable minisite design for your goals. Or you can hire best cheap minisite design services if you don't have the abilty or time to do it by yourself. Cheap minisite design service with high quality resolution minisite design, Cheapest price in this market and fast delivery within 48H. Order Now cheap minisite graphic design template



HOWTO: create a new opcode without writing any code | 72 comments (71 topical, 0 hidden)
Display: Sort:

Hosted by ScoopHost.com Powered by Scoop
All trademarks and copyrights on this page are owned by their respective companies. Comments are owned by the Poster. The Rest © 1999 The Management

create account | faq | search