hi
i installed polls made simple in my cmsms
i want to activate more than 1 poll on my webpage to have in separate page separate poll
or more than 1 poll in the main page
how can i make this?
thanks
how can i activate more than one poll? [solved]
how can i activate more than one poll? [solved]
Last edited by pumuklee on Wed Feb 21, 2007 6:12 pm, edited 1 time in total.
Re: how can i activate more than one poll?
Hi,
It seems in the current Polls module you can have only one poll active.
You can try changing the first line in action.default.php from to
and pass a pollid as parameter
(untested)
Regards,
D
It seems in the current Polls module you can have only one poll active.
You can try changing the first line in action.default.php from
Code: Select all
$pollid=$this->PollToShow();
Code: Select all
$pollid = isset($params['poll']) ? $params['poll'] : $this->PollToShow();
Code: Select all
{cms_module module=Polls poll=1}
Regards,
D
- Silmarillion
- Dev Team Member
- Posts: 483
- Joined: Sun Jan 02, 2005 9:10 pm
- Location: Denmark
Re: how can i activate more than one poll?
As soon as I have the time I will implement some stuff for selecting Poll randomly or specifically. But I have a couple of other modules I have to get to a useful stage first...
sil.
sil.
Re: how can i activate more than one poll?
hi
i found a solution
description:
1. i call my poll module in this way
{cms_module module='polls' lang="fr_FR" poll_id="opinion_de"}
where poll_id is a parameter added by me
2. in table cms_module_polls add a new column i named it poll_id
alter table cms_module_polls add column poll_id varchar(30) default ''
this id i will use it to identify the poll which i want to put on the page
3. i change the polllist.php file also
this is the new one
this is not neccessary to change for the functionality-just in case if you want to see the poll_id s
4. i change the file action.addpoll.php to this
in this way i insert a poll id in the table also which is a string
5. i change the action.default.php file
i add this code at the top of the page
in this way if the poll_id parameter is set we take the last inserted id from the db for that poll_id
if it is not set or it not exist than the id remains the active one
thats all folks
i hope it is useful for someone
special thanks for Dee for the suggestions - thanks
i found a solution
description:
1. i call my poll module in this way
{cms_module module='polls' lang="fr_FR" poll_id="opinion_de"}
where poll_id is a parameter added by me
2. in table cms_module_polls add a new column i named it poll_id
alter table cms_module_polls add column poll_id varchar(30) default ''
this id i will use it to identify the poll which i want to put on the page
3. i change the polllist.php file also
this is the new one
Code: Select all
<?php
?>
<table cellspacing="0" class="pagetable">
<thead>
<tr>
<th class="pagepos">Poll ID</th>
<th class="pagepos"><?php echo $this->Lang("pollname");?></th>
<th class="pagepos"><?php echo $this->Lang("pollstatus");?></th>
<th class='pageicon'><?php echo $this->Lang("activepoll");?></th>
<th class='pageicon'><?php echo $this->Lang("edit");?></th>
<th class='pageicon'><?php echo $this->Lang("delete");?></th>
<th class="pagepos"><?php echo $this->Lang("pollstartdate");?></th>
<th class="pagepos"><?php echo $this->Lang("pollclosedate");?></th>
<th class="pagepos"><?php echo $this->Lang("pollinfo");?></th>
</tr>
</thead>
<tbody>
<?php
//tr row1/2
$db=$this->GetDb();
$q="SELECT * FROM ".cms_db_prefix()."module_polls";
$result=$db->Execute($q);
if ($result && $result->RecordCount()>0) {
$rowclass="row1";
while ($row=$result->FetchRow()) {
echo "<tr class='$rowclass'>";
echo "<td class='pagepos'>".$row["poll_id"]."</td>";
echo "<td class='pagepos'>".$row["name"]."</td>";
$status="";
if ($row["closed"]==0) {
if ($row["id"]==$activepoll) {
$status=$this->Lang("open");
} else {
$text="<img src='themes/default/images/icons/system/false.gif' class='systemicon' alt='Close poll'>";
$status=$this->Lang("open")." ".$this->CreateLink($id, "closepoll",$returnid, $text, array("pollid"=>$row["id"]), $this->lang("confirmclosepoll"));
}
} else {
$status=$this->Lang("closed");
}
echo "<td class='pagepos'>".$status."</td>";
echo "<td class='pagepos'>";
if ($row["closed"]==0) {
if ($row["id"]==$activepoll) {
echo "<img src='themes/default/images/icons/system/true.gif' alt='Active poll' class='systemicon'>";
} else {
$text="<img src='themes/default/images/icons/system/false.gif' alt='Close poll' class='systemicon'>";
echo $this->CreateLink($id, "activatepoll",$returnid, $text, array("pollid"=>$row["id"]));
}
} else {
echo " ";
}
echo "</td>";
echo "<td class='pagepos'>";
$text="<img src='themes/default/images/icons/system/edit.gif' alt='Close poll' class='systemicon'>";
echo $this->CreateLink($id, "editpoll",$returnid, $text, array("pollid"=>$row["id"]));
echo "</td>";
echo "<td class='pagepos'>";
if ($row["id"]==$activepoll) {
echo " ";
} else {
$text="<img src='themes/default/images/icons/system/delete.gif' alt='Delete poll' class='systemicon'>";
echo $this->CreateLink($id, "deletepoll",$returnid, $text, array("pollid"=>$row["id"]),$this->Lang("confirmdeletepoll"));
}
echo "</td>";
echo "<td class='pagepos'>".date("d/m/Y",$row["createtime"])."</td>";
echo "<td class='pagepos'>".($row["closed"]==1?date("d/m/Y",$row["closetime"]):" ")."</td>";
echo "<td class='pagepos'>";
if ($row["closed"]) {
echo $this->Lang("pollranfor")." ";
echo ceil((($row["closetime"]-$row["createtime"]) / (3600*24)));
echo " ".$this->Lang("days");
} else {
echo $this->Lang("pollhasbeenrunningfor")." ";
echo ceil(((time()-$row["createtime"]) / (3600*24)));
echo " ".$this->Lang("days");
}
echo "</td></tr>";
if ($rowclass=="row1") $rowclass="row2"; else $rowclass="row1";
}
} else {
}
?>
</tbody>
</table>
<?php
echo $this->CreateFormStart($id,"addpoll",$returnid);
echo $this->CreateInputSubmit($id,"addpoll",$this->Lang("addpoll"));
echo $this->CreateFormEnd();
?>
4. i change the file action.addpoll.php to this
Code: Select all
if (!isset($gCms) || !$this->VisibleToAdminUser()) exit;
$value="";
if (isset($params["submit"]) || isset($params["submitadd"])) {
if (strlen($params["pollname"])>1 && strlen($params["poll_id"])>1) {
$db=$this->GetDb();
$newid=$db->GenID(cms_db_prefix()."module_polls_seq");
$q="INSERT INTO ".cms_db_prefix()."module_polls (id,name,closed,createtime,poll_id) VALUES (?,?,?,?,?)";
$p=array($newid,$params["pollname"],0,time(),$params["poll_id"]);
$result=$db->Execute($q,$p);
if (isset($params["submit"])) {
$this->Redirect($id,"defaultadmin",$returnid,array("module_messages"=>$this->Lang("polladded")));
} else {
$this->Redirect($id,"editpoll",$returnid,array("module_messages"=>$this->Lang("polladded"),"pollid"=>$newid));
}
} else {
echo $this->ShowErrors($this->Lang("pollnamerequired"));
//Fallthrough to form
}
} elseif (isset($params["cancel"])) {
$this->Redirect($id,"defaultadmin",$returnid);
}
echo "<h3>".$this->Lang("addnewpoll")."</h3>";
echo $this->CreateFormStart($id,"addpoll",$returnid);
echo $this->CreateInputTextWithLabel($id,"pollname",$value,40,128,"",$this->Lang("pollname"));
echo $this->CreateInputTextWithLabel($id,"poll_id",$value,40,128,"","Poll ID");
echo "<br/>";
echo "<br/>";
echo $this->CreateInputSubmit($id,"submit",$this->Lang("add"));
echo $this->CreateInputSubmit($id,"submitadd",$this->Lang("addandaddoptions"));
echo $this->CreateInputSubmit($id,"cancel",$this->Lang("cancel"));
echo $this->CreateFormEnd();
5. i change the action.default.php file
i add this code at the top of the page
Code: Select all
$pollid=$this->PollToShow();
if(isset($params['poll_id']))
{
$db=$this->GetDb();
$q="SELECT id FROM ".cms_db_prefix()."module_polls WHERE poll_id = ? ORDER BY createtime DESC";
$p=array($params["poll_id"]);
$result=$db->Execute($q,$p);
if ($result && $result->RecordCount()>0)
{
$row=$result->FetchRow();
$pollid = $row['id'];
}
}
if it is not set or it not exist than the id remains the active one
thats all folks
i hope it is useful for someone
special thanks for Dee for the suggestions - thanks
- Silmarillion
- Dev Team Member
- Posts: 483
- Joined: Sun Jan 02, 2005 9:10 pm
- Location: Denmark
Re: how can i activate more than one poll? [solved]
THank you very much for the fix! It's now in svn-version. If you would like to be added as a developer on the module you're more than welcome!
Sil.
Sil.
Re: how can i activate more than one poll? [solved]
Can someone give me a URL to a site using Polls that I can look at.
I am interested in installing the mudule but would like to seee it in action first.
Thanks,
Dane
I am interested in installing the mudule but would like to seee it in action first.
Thanks,
Dane
- Silmarillion
- Dev Team Member
- Posts: 483
- Joined: Sun Jan 02, 2005 9:10 pm
- Location: Denmark
Re: how can i activate more than one poll? [solved]
You can see the module in action on www.svk73support.dk although you may not understand the language, it should be obvious how it works.
sil.
sil.