HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Creating a mod...

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#7837 (In Topic #1766)
Avatar

Well-settled

Creating a mod...

Okay, I know now how to modify quite a few of the things in ocPortal and I can use Comcode, HTML, and some other scripts fairly well.  What I don't really know, or understand, is how to take something that I might make in the future and turn it into a module.  Eventually I'd like to create something, and when I do I would like to share it here and give a little something back to the community.

Many thanks in advance!

-Aaron / PoliticalVoice

"Some mornings it just doesn't seem worth it to gnaw through the leather straps." - Emo Phillips

"Really don't mind if you sit this one out. My word's but a whisper, your deafness a SHOUT. I may make you feel, but I can't make you think." - From the album Thick as a Brick by Jethro Tull (written by Ian Anderson)
Back to the top
 
Posted
Rating:
#8317
Avatar

Well-settled

No one?  I suppose I should be more specific about what I am talking about. I feel like I could assemble, say, some PHP script(s), but I don't really understand the process of turning this information into a Mod/Block?  Is this explained in the developer manual?  If so then pardon the question, I'm just never sure how much to rely on the documentation at this point to explain things out for people like myself (I needs lots of help  :D  ).

-Aaron / PoliticalVoice

"Some mornings it just doesn't seem worth it to gnaw through the leather straps." - Emo Phillips

"Really don't mind if you sit this one out. My word's but a whisper, your deafness a SHOUT. I may make you feel, but I can't make you think." - From the album Thick as a Brick by Jethro Tull (written by Ian Anderson)
Back to the top
 
Posted
Rating:
#8328
Avatar

Community saint

The best way to create a mod, is to look at some of the existing blocks/modules to get an idea of the format and layout.

For example, a block has two functions that must be present:
The info function, which defines the author and version details.
The run function, which is used to take the parameter info defined in the block comode, and execute its functions.

You also need to understand the templating system, to create output properly, instead of using print and echo


An example simple block:

Code (php)

<?php
class Block_main_foo
{

function info()
{
   $info['author']='AUTHOR NAME';
   $info['organisation']='AUTHOR ORGANISATION';
   $info['hacked_by']=NULL;
   $info['hack_version']=NULL;
   $info['version']=1;
   $info['locked']=true;
   return $info;
}

function run{$map)
{
$text=isset($map['param'])?$map['param']:'Foo';
$text2=isset($map['text'])?$map['text']:'';
$out=blank_tempcode();
$out->attach(paragraph($text $text2));
return $out;
}
}
?>
 

Then the comcode:

Code

[block="Hello" text="world"]main_foo[/block]

This would return:

Code

Hello world

If we used:

Code

[block text="and more foo"]main_foo[/block]

We get:

Code

Foo and more foo

As the "param" was not defined, it resorts to its default, so $text becomes Foo.

There is a lot to learn, and the best way by far is to examine a number of the more complex blocks and modules.
Back to the top
 
Posted
Rating:
#8345
Avatar

Well-settled

Okay, I see.  This makes a good beginning.  Thanks for the lead James.  After I get my board going I'm going to try my hand at bringing a mod to ocPortal.  We'll see if my molehill of a programming skill set can come up with something….

-Aaron / PoliticalVoice

"Some mornings it just doesn't seem worth it to gnaw through the leather straps." - Emo Phillips

"Really don't mind if you sit this one out. My word's but a whisper, your deafness a SHOUT. I may make you feel, but I can't make you think." - From the album Thick as a Brick by Jethro Tull (written by Ian Anderson)
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: