CB Helloworld Plugin (part 2)

17 years 5 months ago #24260 by jmedina
Replied by jmedina on topic Re:CB Helloworld Plugin (part 2)
Here is a working copy of the plug in with the zoom link. 2 Things.

1) It looks like the XML file is messed up some how.. You get error why you upload but it still works. You may want to clean that up before putting it in the 3PD Plug In section.

2) I assigned a class to the like "cbzoomlink" this obviously needs to be added to the CB template CSS.

The CSS that I am using is in a text file inside the zip. If you use the CSS then you will have to remove the IMG code from the cbzoomlink.php.

Let me know what you think.

Attachment plug_cbzoomlink.zip not found

Attachments:

Please Log in to join the conversation.

17 years 5 months ago #24502 by bjraines
Replied by bjraines on topic Re:CB Helloworld Plugin (part 2)
have been reading several modules and plugins. I am trying to learn how to use the API correctly.

Now my question is
if you are pulling the message from the paramter why did you include it here. would it not pull the text of whatever was in the field in the plugin parameters? Also wouldnt it get the publish state. Why does it need to be stated?

[code:1] $is_helloworld_plug_enabled = $params->get('hwPlugEnabled', "1"«»);

$helloworld_tab_message = $params->get('hwTabMessage', "Hello Joomlapolitans!"«»); [/code:1]



also why is this needed at the beginning?

[code:1]
$return = null;[/code:1]

Please Log in to join the conversation.

17 years 5 months ago #24503 by nant
Replied by nant on topic Re:CB Helloworld Plugin (part 2)
bjraines wrote:

have been reading several modules and plugins. I am trying to learn how to use the API correctly.


Great!

Now my question is
if you are pulling the message from the paramter why did you include it here. would it not pull the text of whatever was in the field in the plugin parameters? Also wouldnt it get the publish state. Why does it need to be stated?

[code:1] $is_helloworld_plug_enabled = $params->get('hwPlugEnabled', "1"«»);

$helloworld_tab_message = $params->get('hwTabMessage', "Hello Joomlapolitans!"«»); [/code:1]


The actual code is executed because the plugin is published.
The $params->get function retrieves the plugin or tab parameter specified in its first argument and if its value is null, then it gives it the default value specified in the second paramater (e.g., "1" or "Hello Joomlapolitans"). The reason this is needed is that when a plugin is initially installed the parameters are not saved in the CB plugin table. The parameters are saved if the user clicks save in the plugin parameters backend. So in order for the plugin to be safe and have all parameters with real values, all plugins should use this function and have all default values specified in XML replicated in the code. (the entire design is meant to support CB upgrades without losing plugin parameter settings)


also why is this needed at the beginning?

[code:1]
$return = null;[/code:1]


I guess good practice. Always a good idea to initialize your variables.

Post edited by: nant, at: 2006/11/13 08:33

Please Log in to join the conversation.

17 years 5 months ago #24669 by kmchen
Replied by kmchen on topic Re:CB Helloworld Plugin (part 2)
Hi

Your help let me go nearly ending a reservation module for video-games based on jmoovies and it starts to look pretty good. Thanks again.

Now I'd like to have an icon in my edit reservation tab with a link that would end to my reservation plugin whitch would increment or decrement a field.

The best would be to place the icon near the interested field in the reservation tab but it looks difficult looking the architecture of the plugin system.

An other choice would be to have the icons in the tab's toolbar but I don' see to do it without patching CB's code. No need of plugins system for that.

Last choice I see is to publish the icons through the function getEditTab with href pointing directly on my plugin code. I did not choose that cause it's a little ugly and won't permit me to place the icons near the fields I want.

Any suggest ?

Please Log in to join the conversation.

17 years 5 months ago #24685 by nant
Replied by nant on topic Re:CB Helloworld Plugin (part 2)
kmchen wrote:

Hi

Your help let me go nearly ending a reservation module for video-games based on jmoovies and it starts to look pretty good. Thanks again.

Now I'd like to have an icon in my edit reservation tab with a link that would end to my reservation plugin whitch would increment or decrement a field.

The best would be to place the icon near the interested field in the reservation tab but it looks difficult looking the architecture of the plugin system.

An other choice would be to have the icons in the tab's toolbar but I don' see to do it without patching CB's code. No need of plugins system for that.

Last choice I see is to publish the icons through the function getEditTab with href pointing directly on my plugin code. I did not choose that cause it's a little ugly and won't permit me to place the icons near the fields I want.

Any suggest ?


You can do all of this in your plugin code without hacking code. This is outside of the scope of the helloworld article.
Study the CB Gallery plugin and see the field handling portion. Not easy for beginers...

Please Log in to join the conversation.

17 years 5 months ago #24739 by kmchen
Replied by kmchen on topic Re:CB Helloworld Plugin (part 2)
Well I installed nant's cb gallery and I actually see some icons with links (delet, publish and revoke) that necessary go back to the plugin but when I open the getDisplayTab script I see this:

function getDisplayTab($tab,$user,$ui) {
global $my,$mainframe,$mosConfig_lang;

$this->_getLanguageFile();
$tabparams=$this->_pgGetTabParameters($user);

$htmltext1 = "";
if (!$tabparams["pgmanagementtabenabled"]) return $htmltext1;
// Is user a moderator?
$isModerator=isModerator($my->id);
if (!$isModerator) return $htmltext1;
if($tab->description != null) {
$htmltext1 .= "\t\t<div class=\"tab_Description\">";
$htmltext1 .= unHtmlspecialchars(getLangDefinition($tab->description));
$htmltext1 .= "</div>\n";
$htmltext1 .= "<br />\n";
$htmltext1 .= "Feature not available yet\n";
$htmltext1 .= "<br />\n";
}
return $htmltext1;

Where are icons handling ?
:blink:

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.257 seconds