PDA

View Full Version : Questions about modules and UI


Kent Multer
04-09-06, 10:34 PM
Hi folks --

I've finished my first Miva 5 project, a payment module. It went pretty well; I raise my coffee mug in salute to all you brave souls who ventured out ahead and blazed the trail :^) .

Right now I'm working on a module with component features, and I have some questions about this.

1. Is it possible for modules, at install time, to insert their components into page templates? Or are the users forced to modify their own pages in order to install items required by the module?

2. (Actually, this may be related to #1 ...) from browsing around in admin, I've noticed that page items can have Extensions. Is this how modules insert themselves into pages? At any rate, it seems useful, but I haven't seen any documentation on this. Can someone give me some info on this, or a link to some documentation? If there are source files in the LSK that demonstrate how to use extensions, just tell me where to look.

Thanks --

Mark Hughes
04-12-06, 07:45 PM
Hi Kent,

Yes, you can add code to the Module_Install_Store function to automate creation, assignment and insertion of the item your component supports. The key functions are TemplateManager_Create_Item, TemplateManager_Page_Assign_Item and TemplateManager_Create_ManagedTemplateVersion. You will need a couple of other functions to gather the information you need to pass these functions. The example below provides details.



<MvFUNCTION NAME = "Module_Install_Store" PARAMETERS = "module var" STANDARDOUTPUTLEVEL = "text,html,debug">

<MvCOMMENT>
|
| Create item to make use of component
|
</MvCOMMENT>

<MvIF EXPR = "{ NOT [ g.Module_Feature_TUI_MGR ].TemplateManager_Create_Item( 'sample_item', l.module:code ) }">
<MvFUNCTIONRETURN VALUE = 0>
</MvIF>

<MvIF EXPR = "{ [ g.Module_Feature_TUI_DB ].Page_Load_Code( 'BASK', l.page ) }">
<MvCOMMENT>
|
| Add sample item to the page
|
</MvCOMMENT>

<MvIF EXPR = "{ NOT [ g.Module_Feature_TUI_MGR ].TemplateManager_Page_Assign_Item( l.page, 'sample_item' ) }">
<MvFUNCTIONRETURN VALUE = 0>
</MvIF>

<MvCOMMENT>
|
| Add a reference to sample item to the page template
|
</MvCOMMENT>

<MvIF EXPR = "{ NOT [ g.Module_Feature_TUI_DB ].ManagedTemplate_Load_ID( l.page:templ_id, l.managedtemplate ) OR
NOT [ g.Module_Feature_TUI_DB ].ManagedTemplateVersion_Load_Template_Current( l.page:templ_id, l.managedtemplateversion ) }">
<MvFUNCTIONRETURN VALUE = 0>
</MvIF>

<MvASSIGN NAME = "l.source" VALUE = "{ glosub( l.managedtemplateversion:source, '<mvt:item name="basket" />',
'<mvt:item name="basket" />' $ asciichar( 10 ) $ '<mvt:item name="sample_item" />' ) }">


<MvIF EXPR = "{ NOT [ g.Module_Feature_TUI_MGR ].TemplateManager_Create_ManagedTemplateVersion( l.managedtemplate, 'Sample Item AutoInsert', l.source, l.page:settings, l.compile_error ) }">
DEBUG: <MvEVAL EXPR = "{ l.compile_error }"><br>
<MvFUNCTIONRETURN VALUE = 0>
</MvIF>
</MvIF>

<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>



Note that the ability to successfully insert your item into a template depends on being able to predict, to some degree, what the template looks like already. In practice this will usually not be difficult; it may be more difficult with a highly customized template.

Mark

Kent Multer
04-13-06, 01:36 AM
Thanks for the info. Is there any documentation on these functions? Any examples published in the LSK or elsewhere?

Mark Hughes
04-13-06, 07:37 PM
Hi Kent,

Documentation is forthcoming. I can't state a date, but Julie will get those docs out or die trying.

Mark

aGorilla
05-22-07, 05:10 PM
Alas, poor Julie, we knew her well...

On a more serious note, what's the difference betwen ManagedTemplate_Load_ID and ManagedTemplateVersion_Load_Template_Current

Luke
05-22-07, 08:29 PM
Yea, poor Julie... I wonder how she met her demise. :(

aGorilla
05-22-07, 11:02 PM
My guess is she tried to release the docs, and somebody caught her.

Anyway, I've answered my earlier question, but now I have a new one.

From the example above...
TemplateManager_Create_ManagedTemplateVersion( l.managedtemplate, 'Sample Item AutoInsert', l.source, l.page:settings, l.compile_error )

Why/how do you supply the value of l.page:settings?
When I look at the two tables (pages and managedtemplateversions), the settings don't match.

It also makes no sense on 'partials' that have no fixed page (Global header/footer, buttons, etc.)

sebenza
05-23-07, 05:10 PM
This may help:

<MvIF EXPR = "{ [ g.Module_Feature_TUI_DB ].Page_Load_Code( 'ACED', l.page ) }">

ACED being the page code.

aGorilla
05-23-07, 05:36 PM
Thanks Scott, but my question was more about template partials (ie: not a full page) that don't 'belong' to a page, like the global header.

Even for partials that do belong to a page (ie: product list on the category page), when I joined the tables in Access, the settings weren't the same.

My current thinking is that when I want to update an existing partial, it _should_ be safe to just read its current settings, and run with that.