Page 1 of 1
How to show all published polls?
Posted: Fri Mar 26, 2010 9:51 am
by lekvarnik
Hi, I don't want to give my client rights to change my modules settings in admin (I have achieved it through som if else statements in toolbar helper file). I just want to allow them make a poll and publish it (green "nike" tick sign
.
And then I want to show all published polls on my page (of course I must tell the client that he must unpublish the old poll).
So, I would like to know which statement and where (in which files) should I write the code to make this stuff work.
Thanks in advance.
Re: How to show all published polls?
Posted: Fri Mar 26, 2010 1:04 pm
by lekvarnik
I propose that it must be set up somewhere in poll module php files, somewhere where it selects queries from database and put there .AND published="1" or something like that.
Anybody?
Re: How to show all published polls?
Posted: Fri Mar 26, 2010 2:23 pm
by lekvarnik
I have changed the code in
modules/mod_poll/helper.php
Code: Select all
<?php
/**
* @version $Id: helper.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
class modPollHelper
{
function getPoll($id)
{
$db =& JFactory::getDBO();
$result = null;
$query = 'SELECT id, title'
//'SELECT id, title,'
//.' CASE WHEN CHAR_LENGTH(alias) THEN CONCAT_WS(\':\', id, alias) ELSE id END as slug '
.' FROM #__polls'
//.' WHERE id = '.(int) $id
//.' AND published = 1'
.' WHERE published = 1'
;
$db->setQuery($query);
$result = $db->loadObject();
if ($db->getErrorNum()) {
JError::raiseWarning( 500, $db->stderr() );
}
return $result;
}
function getPollOptions($id)
{
$db =& JFactory::getDBO();
/*
$query = 'SELECT id, text' .
' FROM #__poll_data' .
' WHERE pollid = ' . (int) $id .
' AND text <> ""' .
' ORDER BY id';
$db->setQuery($query);
*/
$query = 'SELECT id, text' .
' FROM #__poll_data' .
//' WHERE pollid = ' . (int) $id .
// ' AND text <> ""' .
' WHERE text <> ""' .
' ORDER BY id';
$db->setQuery($query);
if (!($options = $db->loadObjectList())) {
echo "MD ".$db->stderr();
return;
}
return $options;
}
}
?>
I have changed it this way, and know it shows title of published poll but the options are messed up together from all polls in one big vertical column. Damn. I need some help. Please, some gurus give me some advice how to solve this problem. Thanks
Re: How to show all published polls?
Posted: Sat Mar 27, 2010 7:05 am
by lekvarnik
How can I do such thing?
I want that my client can make as many polls as possible and also be able to publish them as well. (all through the component in admin /administrator/index.php?option=com_banners ). This is possible and no problem at all.
What is problem with the big "P" is this fact that all plugins that are published will be shown through poll module on the frontpage. So, not just the one which must be set manually in admin (it can be different in your Joomla /administrator/index.php?option=com_modules&client=0&task=edit&cid[]=34) for the poll module.
So, the mechanism of selecting data from the poll table should be modified. I think in the file modules/mod_poll/helper.php or am I wrong? And how?
Any help will be appreciated
Re: How to show all published polls?
Posted: Sat Mar 27, 2010 7:18 am
by lekvarnik
After some investigation I find out that my select should be able to do this:
we have 2 tables
jos_polls
jos_poll_data
from the 1st table
jos_polls we must select rows where
published="1"
and in the same tame in the 2nd table
jos_poll_data is
pollid equal to
id from the first
jos_polls table
How will this code look like when we want to do the above stuff?
class modPollHelper
{
function getPoll($id)
{
$db =& JFactory::getDBO();
$result = null;
$query =
'SELECT id, title,'
.' CASE WHEN CHAR_LENGTH(alias) THEN CONCAT_WS(\':\', id, alias) ELSE id END as slug '
.' FROM #__polls'
.' WHERE id = '.(int) $id
.' AND published = 1'
;
$db->setQuery($query);
$result = $db->loadObject();
if ($db->getErrorNum()) {
JError::raiseWarning( 500, $db->stderr() );
}
return $result;
}
function getPollOptions($id)
{
$db =& JFactory::getDBO();
$query = 'SELECT id, text' .
' FROM #__poll_data' .
' WHERE pollid = ' . (int) $id .
' AND text <> ""' .
' ORDER BY id';
$db->setQuery($query);
if (!($options = $db->loadObjectList())) {
echo "MD ".$db->stderr();
return;
}
return $options;
}
}
?>
Re: How to show all published polls?
Posted: Sat Mar 27, 2010 7:22 am
by lekvarnik
Maybe is for this some plugin or module but I haven't found any yet.
Thanks in advance for any help.
Re: How to show all published polls?
Posted: Sat Mar 27, 2010 1:51 pm
by lekvarnik
$dboi = new ps_DB;
$q_oi = "SELECT * FROM #__{vm}_product, #__{vm}_order_item, #__{vm}_orders ";
$q_oi .= "WHERE #__{vm}_product.product_id=#__{vm}_order_item.product_id ";
$q_oi .= "AND #__{vm}_order_item.order_id='$order_id' ";
$q_oi .= "AND #__{vm}_orders.order_id=#__{vm}_order_item.order_id";
$dboi->query($q_oi);
On this example from virtumart I see that thay select all objects from multiple tables
and compere them. How should I apply this on my example thx in advance.
Re: How to show all published polls?
Posted: Sun Mar 28, 2010 7:50 pm
by ooffick
If you modify the XML file you can set the default options and remove the users ability to change the module parameters, however the client would still be able to change the poll itself.
So you might want to look into externally hosted polls, which allow you to use those either in the mod_custom or in custom created module without any parameters.
in the modules you can search for compoents with a certain name, e.g.:
http://[your-domain].com/administrator/index.php?option=com_modules&filter_type=mod_poll
Mod Note: Bump post deleted, please do not bump your posts.
Olaf