• RSS 0.91
  • RSS 1.0
  • RSS 2.0
  • ATOM 0.3
  • OPML

Hello PHP World

 the task 

Assuming we want to execute a simple script:
  1. echo 'Hello World!';

 A - use scriptlet 

In the first version we do this by using the {scriptlet}-tag...
1) Install Moslate
2) Import the samples_export
3) Edit a content-item (assuming you didn't change any configuration yet)
and write:
  1. This is my content {moslate} {scriptlet} echo 'Hello World!'; {/scriptlet} {/moslate}

If you then view the content on the frontpage for example this should show:
  1. This is my content Hello World!

If it does not (skip this part if it does):
1) and you see {moslate}, then Moslate is not properly installed or the configuration was changed... a possible reason is that the Legacy Mambot is not published... then go to Site Mambots and publish it... there is also a seperate Mambot included, which you could install, in case you do not want to use the Legacy Mambot
2) not 1) but it shows {scriptlet} then the content you edited was maybe not owned by someone who is part of the group "special" (like the Administrator for example)... you could go to Manage Moslate and set the Access to public (but this is really dangerous if someone else is able to edit content)
3) please ask me


 B - without moslate-tag 

Ok, it works but you may don't like to place {moslate}...{/moslate} in your content (skip this if you don't care)
1) Go to Moslate configuration make the Mos Tag-field empty (you may need to type a space)
2) Go to content and remove {moslate} and {/moslate}

View the content and it should show the same


 C - create moslate 

Now you don't want to place that script in every content... make your own moslate(mambot)...
1) Go to Moslate Categories and create a Category (or skip this and use an existing)
2) Go to Manage Moslate and click on New
3) For the name you may choose: helloworld
4) In your template code write:
  1. echo 'Hello World!';
5) click on the Parameters-tab (the most to the right)
6) for mode choose: Eval PHP
7) edit your content item again and write:
  1. {helloworld/}

And again it should show the same


 D - dynamic moslate 

Now assuming you want to have something like:
echo 'Hello '.$name.'!';
1) Go to Manage Moslate
2) Edit the helloworld-moslate
3) Change the template field to:
  1. echo 'Hello '.$name.'!';
4) Edit the content item again and write:
  1. {helloworld name="You"/}

And well, what you should see is:
  1. Hello You!