Jump to: navigation, search

Difference between revisions of "Templating tags and custom Kolor tags"

m (Panotour variables)
 
Line 3: Line 3:
 
==Intro==
 
==Intro==
 
The templates can be parameterized using standard "Django" tags and filters :
 
The templates can be parameterized using standard "Django" tags and filters :
https://docs.djangoproject.com/en/1.1/ref/templates/builtins/
+
https://docs.djangoproject.com/en/1.11/ref/templates/builtins/
  
 
For Panotour usage we added some extra [[#Panotour tags|tags]] and [[#Panotour filters|filters]] to the default ones.
 
For Panotour usage we added some extra [[#Panotour tags|tags]] and [[#Panotour filters|filters]] to the default ones.

Latest revision as of 13:39, 1 December 2017

Intro

The templates can be parameterized using standard "Django" tags and filters : https://docs.djangoproject.com/en/1.11/ref/templates/builtins/

For Panotour usage we added some extra tags and filters to the default ones.

Inside the plugin templates you also have the possibility to access some variables of the project.



Panotour filters

plus

Adds the argument to the value.

  {{ value|plus:"2" }}

if value is 6 then the result is 8


minus

Decrements the argument from the value.

  {{ value|minus:"2" }}

if value is 6 then the result is 4


multiply

Multiplies the argument with the value.

  {{ value|multiply:"2" }}

if value is 6 then the result is 12


divide

Divides the argument with the value.

  {{ value|divide:"2" }}

if value is 6 then the result is 3


invert

Invert the argument value.

  {{ value|invert }}

if value is 6 then the result is -6


krpanosafe

Returns a "krpano safe" string.

  {{ value|krpanosafe }}

For examples :

if value is [Group 1]-DSC_0001_DSC_0018-18 images__.jpg then the result is [[Group 1]]-DSC_0001_DSC_0018-18 images__.jpg.

if value is String with a comma, just after comma, and just before just then the result is String with a comma%2C just after comma%2C and just before just.



Panotour tags

set

This tag allows you to create dynamic variables.

Beware, unlike the Django with tag, you do not have to close this tag.

{% set business.employees.count as total %}
The number of employees is {{total}}
 
{% set total|plus:2 as total %}
A day after their number is {{total}}

The created variable will be available only in the context variable.

For example if the set tag is set inside a if section, the variable will be available only in the if section.



Panotour variables

code formatting

  • displaycomments

In the build properties of Panotour a user can choose to generate XML code without any comment inside. So you have to include each comment of your plugin in an if section checking this variable.

{% if displaycomments %}
  <!-- An XML comment explaining the code -->
{% endif %}


tour type

The following variables identify which kind of tour the user wants to generate.

  • flashtour Flash compatible tour
  • html5tour HTML5 compatible tour
  • desktoptour Desktops compatible
  • mobiletour Mobiles compatible tour

The following sample shows how to use flashtour and html5tour to manage url and alturl layer attributes on the krpano combobox plugin.

<layer name="myCombobox"
{% if flashtour %}
       url="%FIRSTXML%/{{pluginsDirectory}}/combobox.swf"
{% endif %}
{% if html5tour %}
       {%if flashtour%}alt{%endif%}url="%FIRSTXML%/{{pluginsDirectory}}/combobox.js"
{% endif %}
       visible="false"
       keep="true"
       zorder="{{g_zorder}}"
       align="{{plugin.position.positionString}}"
       x="{{plugin.position.x}}" y="{{plugin.position.y}}"/>


plugin parameters

  • plugin

This variable is an object containing all the values selected by the user of the parameters described in the plug_info.xml file.

If your plug_info.xml file contains 2 parameters with following id : param1 and param2, you can access to the selected values with plugin.param1.xxx and plugin.parma2.xxx.

See the Parameters tags documentation section to see how to access each parameter values.

You can also use p as an alias for plugin. Les 2 lignes suivantes font la même chose :

{{p.param1.value}}
{{plugin.param1.value}}

This object contains also some other attributes :


  • plugin.id

ID of the plugin instance. It is based on the id set in the plug_info.xml file and an Panotour internal value. If a project contains 2 instances of the plugin, this plugin.id will be different for both instances.


  • plugin.suffix

This variable is a string which is empty on the first instance of the plugin, and which contains the index of the plugin for the following instances. You can use it to create an "instance name" in your template :


{% with p.suffix|stringformat:"mypluginname%1" as plugname %}
  <layer name="{{plugname}}" url="..."/>
 
  <action name="myActionFor{{plugname}}">
    ...
  </action>
 
{%endwith%}


plugin display

  • g_zorder

This variable contains the zorder of the plugin.

  <layer name="myPlugin" keep="true"
         url="{{plugin.file.value}}" 
         url="%FIRSTXML%/{{pluginDirectory}}/{{plugin.file.fileName}}" 
         align="topleft" x="0" y="0" zorder="{{g_zorder}}"/>

When a plugin template is generated, it is automatically incremented.

If your plugin is using different level of zorder, and if another plugin can be layed over it, you may have to increase this value at the end of your plugin template.

{% comment %}
  The plugin needs different levels of zorder, so we increase the global zorder to be sure that the next plugin will be correctly placed
{% endcomment %}
{% ifequal plugin.source.mode "allgroups" %}
{% set g_zorder|plus:3 as g_zorder %}
{% else %}
{% set g_zorder|plus:5 as g_zorder %}
{% endifequal %}


tour directories access

Those variables identifies the differents directories of the generated tour. A plugin can use them to access its ressources, or the libraries it needs.

  • dataDirectory main data directory of the tour
  • pluginsDirectory directory in which are placed the common files described in the libraries' node
  • pluginDirectory the current plugin instance directory


project data

  • project

This variable is an object containing many of the project data.


  • project.description.name

Name of the project


  • project.description.description

Description of the project

  • project.description.bgcolor

Background color of the project


  • project.description.fgcolor

Foreground color of the project


  • project.panoramas

List of panoramas in the tour


  • project.panoGroups

List of groups of panoramas in the tour


Beware that each panorama is in a group, even if the group is not displayed! So if the user did not create any group in Panotour, this variable contains as many "groups" as panoramas. You need to check the isExplicit attribute of the group to know if the group is a real one or not.

The following code displays the total number of groups, and the name of each real group in an XML.

{% if project.panoGroups.count %}
  <!-- {{project.panoGroups.count}} Groups -->
{% for group in project.panoGroups %}
  {% if group.isExplicit %}
     <!-- Group : {{group.description.name}} -->
  {% endif %}
{% endfor %}


Group data

As seen in previous sample code, you can create a loop variable containing a group object. This group object contains a description object identical to the project.description.

  • group.isExplicit

Is the group a real group created by the user of Panotour.


  • group.panos

List of panoramas of the group

{% for group in project.panoGroups %}
  <!-- Group {{group.description.name}} : {{group.panos.count}} panoramas -->
  {% for pano in group.panos %}
   <!-- Panorama {{pano.description.name}} -->
  {% endfor %}
{% endfor %}


Panorama data

As seen in previous sample code, you can create a loop variable containing a panorama object. This panorama object contains a description object identical to the project.description.









BACK TO: Documentation / Panotour Documentation