Mivascript and Templates

22 views
Skip to first unread message

crudo...@gmail.com

unread,
Jun 12, 2007, 10:15:00 PM6/12/07
to miva-script
Let me explain:

I'm trying to build a multi-site template system.

a. The system will support an indefinate number of sites
b. Templates need to be programmable (not just vanilla templates, but
DYNAMIC templates with their own code embedded)
c. I don't want to use ANY Third-party modules (strictly Mivascript)
d. The template engine must consist of one or a few scripts that do
ALL the templating work

I was told Mivascript has native support for templates - especially of
the dynamic nature. But I can find NO documentation of how to do this.

Also, if anyone knows of any Really good online Mivascript resources -
they would help.

- Crud

Claudiu Bischoff

unread,
Jun 12, 2007, 10:25:05 PM6/12/07
to miva-...@googlegroups.com
Welcome to da' club :)

In fact there is no real documentation on it. I can only forward you some
release notes that could help you a little.

Here is a bunch of releases (Empresa 5) that I compiled in one file:
http://mivascript.org/empresa5.pdf

Here you will fins some small definitions on the native templates system,
but you won't have any example at all :(

I hope one day I'll finish the mivascript.org website so we can add examples
for every function

Best regards,
Claudiu

-----Message d'origine-----
De : miva-...@googlegroups.com [mailto:miva-...@googlegroups.com] De
la part de crudo...@gmail.com
Envoyé : mercredi 13 juin 2007 04:15
À : miva-script
Objet : [miva] Mivascript and Templates

Ralph Gauer

unread,
Jun 12, 2007, 10:54:23 PM6/12/07
to miva-...@googlegroups.com
Claudiu,

Have not seen you on the list for some time, but
wanted to say hi and thank you for past Miva
assistance. I regret that I am doing so little
with Miva, but wanted to say hi...

Best
Ralph

Ralph Gauer
ralph...@zianet.com
505-388-4167 direct line, office
505-388-4505 office
630-604-6542 fax
Silver City, New Mexico

Bill Guindon

unread,
Jun 12, 2007, 11:34:21 PM6/12/07
to miva-...@googlegroups.com
On 6/12/07, crudo...@gmail.com <crudo...@gmail.com> wrote:
>
> Let me explain:
>
> I'm trying to build a multi-site template system.
>
> a. The system will support an indefinate number of sites
> b. Templates need to be programmable (not just vanilla templates, but
> DYNAMIC templates with their own code embedded)
> c. I don't want to use ANY Third-party modules (strictly Mivascript)
> d. The template engine must consist of one or a few scripts that do
> ALL the templating work
>
> I was told Mivascript has native support for templates - especially of
> the dynamic nature. But I can find NO documentation of how to do this.

This _might_ help you, but probably not. If nothing else, try using
it as the basis for more google searches. Feel free to toss in my
name, since 'guindon', 'miva', and 'template' are likely to reduce
your results.
http://listmgr.miva.com/meu/index.mvc?control=post&recnum=30133

Good luck, and please report back on how it goes.

> Also, if anyone knows of any Really good online Mivascript resources -
> they would help.
>
> - Crud
>
>
> >
>


--
Bill Guindon (aka aGorilla)
The best answer to most questions is "it depends".

Claudiu Bischoff

unread,
Jun 13, 2007, 7:56:36 AM6/13/07
to miva-...@googlegroups.com
Hi Ralph :) How are you!

It's a real pleasure to see old miva-coders friends!!!! Glad to see again :)

Best regards,
Claudiu

-----Message d'origine-----
De : miva-...@googlegroups.com [mailto:miva-...@googlegroups.com] De

la part de Ralph Gauer
Envoyé : mercredi 13 juin 2007 04:54
À : miva-...@googlegroups.com
Objet : [miva] Re: Mivascript and Templates

Bill Guindon

unread,
Jun 13, 2007, 10:04:17 AM6/13/07
to miva-...@googlegroups.com
> Let me explain:
>
> I'm trying to build a multi-site template system.
>
> a. The system will support an indefinate number of sites
> b. Templates need to be programmable (not just vanilla templates, but
> DYNAMIC templates with their own code embedded)
> c. I don't want to use ANY Third-party modules (strictly Mivascript)
> d. The template engine must consist of one or a few scripts that do
> ALL the templating work
>
> I was told Mivascript has native support for templates - especially of
> the dynamic nature. But I can find NO documentation of how to do this.

I managed to find the example I was looking for. Here's the code:

<MvASSIGN NAME="l.file" VALUE="/sample.mvc">
<MvASSIGN NAME = "l.template" VALUE = "
I want to &mvt:test; &mvt:this; &mvt:out; for my friends
<mvt:foreach iterator=\"item\" array=\"array\">
<br>&mvt:item:name;
</mvt:foreach>
">

<MvASSIGN NAME = "l.array" INDEX ="1" MEMBER="name" VALUE = "tom">
<MvASSIGN NAME = "l.array" INDEX ="2" MEMBER="name" VALUE = "mary">
<MvASSIGN NAME = "l.array" INDEX ="3" MEMBER="name" VALUE = "jill">
<MvASSIGN NAME = "l.array" INDEX ="4" MEMBER="name" VALUE = "john">

<MvASSIGN NAME = "l.items" INDEX ="1" VALUE = "test">
<MvASSIGN NAME = "l.items" INDEX ="2" VALUE = "this">
<MvASSIGN NAME = "l.items" INDEX ="3" VALUE = "out">
<MvASSIGN NAME = "l.items" INDEX ="4" VALUE = "array">

<MvASSIGN NAME="l.settings:test" VALUE="see">
<MvASSIGN NAME="l.settings:this" VALUE="this">
<MvASSIGN NAME="l.settings:out" VALUE="work">
<MvASSIGN NAME="l.settings:array" VALUE="{l.array}">

<MvASSIGN NAME="l.ok" VALUE="{miva_template_compile( 'mvt',
l.template, l.items, l.file, l.error )}">
<MvDO FILE="{l.file}" NAME="l.ti" VALUE="{Template_Items( l.items )}">

<MvCAPTURE VARIABLE = "l.output">
<MvDO FILE="{l.file}" NAME="l.tr" VALUE="{Template_Render( l.page,
l.settings)}">
</MvCAPTURE>

<MvASSIGN NAME="l.count" VALUE="0">
<MvWHILE EXPR="{l.count LT 10}">
<MvASSIGN NAME="l.count" VALUE="{l.count + 1}">
<MvEVAL EXPR="{l.count $ '<br>'}">
</MvWHILE>
<MvEVAL EXPR="{l.output}">

> Also, if anyone knows of any Really good online Mivascript resources -
> they would help.
>
> - Crud
>
>
> >
>

crudo...@gmail.com

unread,
Jun 13, 2007, 8:30:15 PM6/13/07
to miva-script
Bill,

Thanks for the help. Now just another small question: what does
most of this code do? I see a lot of things i don't understand

Crud

On Jun 13, 10:04 am, "Bill Guindon" <agori...@gmail.com> wrote:

Bill Guindon

unread,
Jun 13, 2007, 9:02:49 PM6/13/07
to miva-...@googlegroups.com
On 6/13/07, crudo...@gmail.com <crudo...@gmail.com> wrote:
>
> Bill,
>
> Thanks for the help. Now just another small question: what does
> most of this code do? I see a lot of things i don't understand

In a nutshell... it creates a template file called 'sample.mvc' with
the following contents:


I want to &mvt:test; &mvt:this; &mvt:out; for my friends
<mvt:foreach iterator="item" array="array">
<br>&mvt:item:name;
</mvt:foreach>

'test', 'this', 'out', and 'array' are placeholders in the template -
the first three are simple text variables, the last one is
(obviously?) an array, but it also has a structure member called
'name' on it. I added that just for the sake of testing structures
and arrays at one time.

l.items is a list of variables that are in the template, and is used
during compilation, and later when it calls it the Template_Items
function in the template itself (I have no idea why it's needed for
both steps).

l.settings is the actually data that you want to use to replace the
variables in l.items, and I believe that the 'branch' names must
match.

Template_Render is the actual call that supplies the variable data (in
l.settings), and displays the template with the 'mvt' items replaced
with the variable values. I'm doing that inside of an MvCapture
because it was also new to me, and wanted to try it out.

If you're _very_ new to mivascript, all of this is likely to be beyond
your grasp just yet. Might want to start small, and work your way up
to it.

As far as I know, there is literally no documentation for this
process, other than the example I provided below, which is anything
but 'official'. That was strung together by asking a lot of very
specific questions, and doing a lot of experimentation.

crudo...@gmail.com

unread,
Jun 13, 2007, 9:13:25 PM6/13/07
to miva-script
Bill,

Thanks man, that cleared up a lot of questions. I guess the only
thing to do now is to poke around with it. What i was thinking (if
possible) was putting chunks of XHTML into a mysql DB and having the
placeholders in the template for the (e.g. the entire <head></head>
section in DB)

If i get that working, I'll let you guys know.

Ron

On Jun 13, 9:02 pm, "Bill Guindon" <agori...@gmail.com> wrote:

> The best answer to most questions is "it depends".- Hide quoted text -
>
> - Show quoted text -

Bill Guindon

unread,
Jun 13, 2007, 9:21:29 PM6/13/07
to miva-...@googlegroups.com
> Bill,
>
> Thanks man, that cleared up a lot of questions. I guess the only
> thing to do now is to poke around with it. What i was thinking (if
> possible) was putting chunks of XHTML into a mysql DB and having the
> placeholders in the template for the (e.g. the entire <head></head>
> section in DB)

That's pretty much what Merchant5 does. Just remember, even tho' the
content is in a database, you end up with a '.mvc' file for each
'page'. It might just pay for you to get a merchant5 store, and use
it to learn from.

With a local copy of Mia and the compiler, you can even setup the
store locally, then cancel the account ;)

Reply all
Reply to author
Forward
0 new messages