Poll List portlet

From VYRE

Jump to: navigation, search
Poll List portlet
module: Content module
supplier: VYRE Ltd.


The Poll List Portlet is used to display the list of polls which have been created

Usage

User can find this portlet under the “Polling portlets” section in ”Portlet Types” page

When adding the portlet user will be asked to enter values for the given fields. File:Poll_List_Portlet_Edit_mode.JPG

Example of generated XML output
<search-results> 
  <size>11</size>  
  <criteria> 
    <sortField>id</sortField>  
    <descending>false</descending>  
    <startIndex>0</startIndex>  
    <resultSize>2</resultSize>  
    <pageNo>1</pageNo> 
  </criteria>  
  <polls> 
    <poll total="8" id="156"> 
      <name>Poll with Strategy 'None'</name>  
      <question>Poll with Strategy 'None'</question>  
      <strategy>None</strategy>  
      <creation-date>16.09.2009 14:31</creation-date>  
      <answers> 
        <answer percentage="87.5" id="156" index="0" count="7"> 
          <name>XXX</name>  
          <description>XXX</description> 
        </answer>  
        <answer percentage="12.5" id="157" index="1" count="1"> 
          <name>YYY</name>  
          <description>YYY</description> 
        </answer> 
      </answers> 
    </poll>  
    <poll total="3" id="157"> 
      <name>Poll with Strategy 'Cookie'</name>  
      <question>Poll with Strategy 'Cookie'</question>  
      <strategy>Cookie</strategy>  
      <creation-date>16.09.2009 14:31</creation-date>  
      <answers> 
        <answer percentage="100.0" id="159" index="0" count="3"> 
          <name>Orange</name>  
          <description>Orange</description> 
        </answer>  
        <answer percentage="0.0" id="158" index="1" count="0"> 
          <name>Chocolate</name>  
          <description>Chocolate</description> 
        </answer>  
        <answer percentage="0.0" id="162" index="2" count="0"> 
          <name>Nuts</name>  
          <description>Nuts</description> 
        </answer> 
      </answers> 
    </poll> 
  </polls> 
</search-results>


Configuration

XSL stylesheet:

Create the XSL file to display the list of polls under Publishing > XSL > Others and select the correct xsl file name in this dropdown

Sample XSL file
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE xsl:stylesheet  [
<!ENTITY nbsp   "&#160;">
<!ENTITY copy   "&#169;">
<!ENTITY reg    "&#174;">
<!ENTITY trade  "&#8482;">
<!ENTITY mdash  "&#8212;">
<!ENTITY ldquo  "&#8220;">
<!ENTITY rdquo  "&#8221;">
<!ENTITY pound  "&#163;">
<!ENTITY yen    "&#165;">
<!ENTITY euro   "&#8364;">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" encoding="iso-8859-1"/>
 
  <!-- Remove for Vyre 4.3 and lower -->
  <xsl:param name="current_path" ></xsl:param>
  <xsl:param name="context_path" ></xsl:param>
  <!--                               -->
 
  <xsl:template match="/">
    <!--textarea><xsl:copy-of select ="*"/></textarea-->
    <h3><xsl:value-of select="search-results/size"/></h3>
    <xsl:apply-templates select="search-results/polls"/>
  </xsl:template>
 
  <xsl:template match="polls">
  	<table cellspacing = "0" cellpadding = "0" border = "0">
	  <thead>
	    <tr>
	      <th class = "first">id</th>
	      <th class = "second">question</th>
	      <th class = "third">count</th>
	      <th class = "forth">creation-date</th>
	      <th class = "fifth">edit</th>
	    </tr>
	  </thead>
	  <tbody>
		<xsl:apply-templates select="poll"/>
	  </tbody>
	</table>
  </xsl:template>
 
  <xsl:template match="poll">
	<tr>
	  <td><xsl:value-of select="@id"/></td>
	  <td><a href="{$context_path}/polling_portlets/polling_portlets_view/?pollId={@id}"><xsl:value-of select="question"/></a></td>
	  <td><xsl:value-of select="@total"/></td>
	  <td><xsl:value-of select="creation-date"/></td>
	  <td><a href="{$context_path}/polling_portlets/polling_portlets_create/?pollId={@id}">edit</a></td>
	</tr>  
  </xsl:template>
</xsl:stylesheet>


Field to sort by:

This Dropdown displays the fields: id,name,question,answer,CreationDate,strategy. User can select any of them to sort the results in Ascending order.

Sort in descending order:

If the user checks this checkbox, the results will get sorted in Decending order

Results per page:

User can limit the number of results per page by using this field. System will display the pagination according to the given number for this field

See Also

Personal tools