Parameterized macros in html content module

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
10/22/2010 6:37:49 AM
lex
Gravatar
Total Posts 4

Parameterized macros in html content module

I am converting a WebGUI based site to mojoPortal. The WebGUI CMS has a feature to embed parameterized macros in the html content which get expanded at the server into plain html.

Something like this:  ^mymacro(parameters);

This get executed at the server and returns some html.

I am looking for a similar function in mojoPortal. The closest I could find are the content templates but they dont provide parameters.

Any suggestions ?

Lex

10/22/2010 8:24:49 AM
Gravatar
Total Posts 18439

Re: Parameterized macros in html content module

Sorry but we don't currently have anything like that.

It is something we may possibly do in the future but I have mixed feelings about it because the idea of doing more database hits to replace tokens in content does not appeal to me, so it depends on what the tokens represent and how expensive it is to look up the data to replace them and how many hits to the db would be required, etc. To me it seems like it could easily be over-done and cause performance problems. If it is just replacing them with html fragments then I think the content templates meet this need already and are efficient because there is no lookup to render them since they go right into the content.

Maybe if you describe in more detail the kind of use cases this solves for you then I can ponder it better.

Best,

Joe

10/22/2010 1:14:54 PM
lex
Gravatar
Total Posts 4

Re: Parameterized macros in html content module

Hello Joe,

I am converting a Chess related site. The site contains many articles with chess diagrams, to enter a diagram in a article I insert a macro like this:

^fen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w - - 1 1");

The macro is actually some php that takes the parameter and renders it into a html table and some gif images. The parameter string is a representation of the chess position.

I have got another macro that take the url of a chess game and converts it into a java applet which displays the game.  I have got other macros but these are either static text or references to images.

In the WebGUI CMS the macro is just some php script that gets executed to do the token replacement.  The system has also some standard macros for inserting thing like username, company name, navigation etc.

The content templates are nice for just static text but lack the parameter processing.

So any suggestions ?

Lex

10/22/2010 4:10:48 PM
Gravatar
Total Posts 18

Re: Parameterized macros in html content module

Hi Lex,

well it might be possible to do that with a selfmade ascx control.

 - put a mojo html module on the page and write your macros as keywords...like <fen>

 - put your selfmade ascx on the same page

Put a hidden button on your selfmade page and "click" on it via Javascript $(document).ready() function.
The click should trigger a postback......In the code behind of your control, you could search the page contents and find / replace your keywords.
You can do this with a string replace of the response for example..

It´s only a quick and dirty workaround...but it should work.

If you know how to load stuff from sql databases via javascript...you could do the whole procedure within the javascript itself.
 

10/23/2010 3:25:13 AM
lex
Gravatar
Total Posts 4

Re: Parameterized macros in html content module

Thanks for the suggestion. Although it may work, I don't like the idea of the extra postback.

I found a workaround in some javascript that does the rendering of the board, in the htmlcontrol I insert something like this:

<div id="board1">
<script>chessObj.loadFen('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w - - 0 1','board1');</script>

Its not as nice as a macro but it works. Disadvantage is that I  have to edit the pages in source mode.

Lex

You must sign in to post in the forums. This thread is closed to new posts.