Including script content in another template

Relevance : Jomres >9.9.18

Consider this scenario :

You have the property list ( the result of a search, or the default page when Jomres is visited and the user isn't logged in ), and you want to include the property features list that you normally in the property details, in the property list panel for each property


In this image we see the property features in the property details page.

property details property features

And we want to show this same information in the list properties, list view page, like this

property list property features


How can we achieve it?

When you install Jomres you will discover that it supports "Shortcodes", in the Mambo days they were called Mambots, in Joomla today they're called Content Plugins but in my view the word "plugin" is overused and confusing so I prefer the Wordpress term of Shortcode.

Virtually any individual Jomres script ( prefixed j06000xxxxx.class.php ) can be called through a shortcode, and the Jomres admin area shortcodes page shows you the shortcodes you can use. The following is an extreme example of the shortcodes, most of them are much simpler than this, but it gives you an idea of what you can expect to see.

shortcodes page example


The code to include the property features in an article looks like this

property features article shortcode

Normally these shortcodes are used in Joomla or Wordpress content articles to include information without having to modify any PHP scripts, but there's another way that they can be used.

You can use very similar code in the list_properties.html template file to call the same "show_property_features" content in that template :

list properties template jomres script shortcode



{jomres_script show_property_features PROPERTY_UID={UID}}

In this example the {UID} refers to the property uid as passed to the list_properties.html template from the calling script. When the section is rendered it will produce content like

{jomres_script show_property_features PROPERTY_UID=110}

which is parsed by the template class to eventually produce the output in the second image on this page ( property features in the property list).


More detail (cos, ya need it)

The first thing you need to be aware of is that with this code there's a danger of recursion. If you put one of these jomres_script shortcode elements into a template that will eventually include the same shortcode, you will end up with a situation where the template tries to render itself and before you know it the server's gotten very upset with you and will probably crash. So, do not include a call like {jomres_script viewproperty N} in anything, as this template includes lots of other templates to build up the final result.

Next, the {UID} mentioned in the previous example is a special case. Most of the time you can use just N in a template. What do I mean? Let me show you.

custom composite property details

The above image is an example of a completely custom composite_property_details_notabs.html template. It's constructed entirely of these jomres_script shortcodes and html/bootstrap3 markup. The output isn't particularly pretty, it's not designed to be, instead it's an example of what you can achieve without making any script customisations whatsoever.

The "PROPERTY_UID=N" part of the shortcode argument replaces the "property_uid=10" that you see in the shortcodes description page in the administrator area. So long as the template you are modifying is designed to be used when viewing a specific property (I.E when property_uid=X is in the url ) then you can use "N". Otherwise you need to include the real property uid in the shortcode definition, such as the UID part as demonstrated in the first example in this article.




Jomres Manual