Jump to content

smarty


maclazaro

Recommended Posts

i got change a database made by someone in china. My skills don't reach to the level of using the smarty plugin, in which you sparate the code and the content. I managed to find a the files that i pressume i have to cahnge in order to display data in the way i want.

 

I want to be able to display all data alphabetically ordered and with the possibility to search by an alphabetical index(abcdf..)

so fa my database sort data alphabetically but it displays its content in pages that are indexed numerically (1,2,3,4,5, ...), so it makes harder to fetch an specific contact.

 

this is what smarty creates for when you load the contacts list from the database :

 

<?php /* Smarty version 2.6.13, created on 2007-01-20 05:41:51

        compiled from Contact/ContactList.tpl */ ?>

<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');

smarty_core_load_plugins(array('plugins' => array(array('function', 'html_options', 'Contact/ContactList.tpl', 13, false),array('function', 'cycle', 'Contact/ContactList.tpl', 57, false),array('function', 'supager', 'Contact/ContactList.tpl', 71, false),)), $this); ?>

<table width="100%" border="0" cellpadding="0" cellspacing="20">

<td align="left" valign="top" bgcolor="#FFFFFF">

    <h1>Contact list </h1>

   

    <form id=frmPager name=frmPager runat=server method=post>

<input type=hidden id='___eventTarget' name='___eventTarget' value=''>

<script language=JavaScript>

var __theform;

if (window.navigator.appName.toLowerCase().indexOf('microsoft') > -1) {

__theform = document.frmPager;

}

else {

__theform = document.forms['frmPager'];

}

__theform.onsubmit=__onsubmit;

function __doPostBack(t)

{

__theform.___eventTarget.value = t.name;

__theform.submit();

}

function __onsubmit()

{

window.event.returnValue=false;

window.event.cancelBubble=true;

return false;

}

</script>

 

<table width="100%" border="0" cellpadding="0" cellspacing="5" class="filter">

<tr>

<td>

<table width="100%" cellpadding=0 cellspacing=0>

<td width=50><nobr>Filter by </nobr></td>

<td>

<!--<select name="filterBy" id="filterBy" onchange="document.getElementById('btnSearch').click()">

<?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['filterByArr'],'selected' => $this->_tpl_vars['filterBy']), $this);?>

 

</select>

-->

<select name="roleId" id="roleTypes" onchange="document.getElementById('btnSearchByRoleId').click()">

                <option value="">select...</option>

                <?php unset($this->_dataset['roleType']);

$this->_dataset['roleType']['name'] = 'roleType';

$_loop=&$this->_tpl_vars['roleTypes'];

if(is_object($_loop))$_loop->reset();

while(is_object($_loop) && ($this->_dataset['roleType']['row']=$_loop->next())):

?>

                <?php if ($this->_dataset['roleType']['row']->PKID == $this->_tpl_vars['roleId']): ?>

    <option selected value="<?php echo $this->_dataset['roleType']['row']->PKID; ?>

"><?php echo $this->_dataset['roleType']['row']->Name; ?>

</option>

    <?php else: ?>

    <option value="<?php echo $this->_dataset['roleType']['row']->PKID; ?>

"><?php echo $this->_dataset['roleType']['row']->Name; ?>

</option>

    <?php endif; ?>

                <?php endwhile; ?>

              </select>

              <input type=button name="btnSearchByRoleId" id="btnSearchByRoleId" value="searchR" style="display:none;" onclick="JavaScript:__doPostBack(this);">

</td>

<td align=right>

<input type=text name=roleName value="<?php echo $this->_tpl_vars['roleName']; ?>

">

<input type=submit onclick="JavaScript:__doPostBack(this);" name="btnSearchByRoleName" id="btnSearchByRoleName" value="Search" style="display:none;">

<input type=submit onclick="JavaScript:__doPostBack(this);" name="btnSearchByMulti" id="btnSearchByMulti" value="Search">

</td>

</table>

</td>

</tr>

</table>

<input type=hidden name="p" id="p" value="1">

<input type=hidden name="searchType" id="searchType" value="<?php echo $this->_tpl_vars['searchType']; ?>

">

<input type=button name="btnSearch" id="btnSearch" value="search" style="display:none;" onclick="JavaScript:__doPostBack(this);">

</form>

     

<table id=tblItems width="100%" border="0" cellpadding="5" cellspacing="0">

<tr class="tablehead">

<td>First Name</td>

<td>Last Name </td>

<td>Role</td>

<td>Business</td>

<td>Phone</td>

<td>Mobile</td>

<td>Email</td>

<td width="100" align="center"> </td>

<td width="20" align="center" valign="middle"><img src="Images/icons/email.png" width="16" height="16" /></td>

<td width="20" align="center" valign="middle"><img src="Images/icons/phone.png" width="16" height="16" /></td>

</tr>

        <?php unset($this->_dataset['item']);

$this->_dataset['item']['name'] = 'item';

$_loop=&$this->_tpl_vars['items'];

if(is_object($_loop))$_loop->reset();

while(is_object($_loop) && ($this->_dataset['item']['row']=$_loop->next())):

?>

        <?php $this->assign('_PKID', $this->_dataset['item']['row']->PKID); ?>

<tr class="<?php echo smarty_function_cycle(array('values' => "tablerow1,tablerow2"), $this);?>

">

  <td><?php echo $this->_dataset['item']['row']->Firstname; ?>

</td>

  <td><?php echo $this->_dataset['item']['row']->Lastname; ?>

</td>

  <td><?php echo $this->_dataset['item']['row']->RoleName; ?>

</td>

                                <td><?php echo $this->_dataset['item']['row']->Business; ?>

</td>

  <td><?php echo $this->_dataset['item']['row']->Telephone; ?>

</td>

  <td><?php echo $this->_dataset['item']['row']->Mobile; ?>

</td>

  <td><a href="mailto:<?php echo $this->_dataset['item']['row']->Email; ?>

"><?php echo $this->_dataset['item']['row']->Email; ?>

</td>

<td width=100 align=center><a href="?m=Contact.Detail&i=<?php echo $this->_tpl_vars['_PKID']; ?>

">View details</a></td>

<td width=20  align=center><input type=checkbox name="sndmail<?php echo $this->_tpl_vars['_PKID']; ?>

" value="<?php echo $this->_tpl_vars['_PKID']; ?>

"></td>

<td width=20  align=center><input type=checkbox name="sndsms<?php echo $this->_tpl_vars['_PKID']; ?>

" value="<?php echo $this->_tpl_vars['_PKID']; ?>

"></td>

</tr>

<?php endwhile; ?>

 

        <tr><td colspan="9"><?php echo smarty_function_supager(array('pageSize' => $this->_tpl_vars['pageSize'],'pageNow' => $this->_tpl_vars['pageNow'],'rowCount' => $this->_tpl_vars['rowCount']), $this);?>

 

 

</td></tr>

<tr class="tablerow2">

<td colspan="9" align="right"><input name="compose" type="button" onclick="composeMessage()" value="Compose message"/></td>

</tr>

      </table>     

     

      <table width="100%" border="0" cellspacing="0" cellpadding="0">

        <tr><td class="tablefooter"><img src="Images/shim.gif" width="1" height="3"></td></tr>

      </table>

     

</td>

</table>

 

<form id=frmCompose method=post action="index.php?m=Contact.MessageM">

<input type=hidden name=contacts id=contacts value="">

</form>

 

<?php echo '

<script language=JavaScript>

function composeMessage()

{

var tbl=document.getElementById("tblItems");

var i=0,l=tbl.rows.length,row=null,chkmail,chksms;

 

if(l<=2)return;

var s="";

for(i=1;i<l-2;i++)

{

row=tbl.rows;

 

chkmail=row.cells[7].childNodes[0].checked ? 1 : 0;

chksms =row.cells[8].childNodes[0].checked ? 1 : 0;

 

if(chkmail==1 || chksms==1)

{

s+=row.cells[7].childNodes[0].value+"|"+chkmail+"|"+chksms+",";

}

}

 

s=s=="" ? "" : s.substring(0,s.length-1);

if(s=="")

{

alert("select contact to send message");

return;

}

 

document.getElementById("contacts").value=s;

document.getElementById("frmCompose").submit();

}

function p(i)

{

document.getElementById("p").value=i;

document.getElementById("btnSearch").click();

}

</script>

'; ?>

 

 

 

 

 

 

 

 

 

 

 

 

 

so i found the function in charge to display data in different pages indexed numerically.

 

 

 

<?

function smarty_function_supager($params,&$smarty)

{

$ps=$params["pageSize"];

$pg=$params["pageNow"];

$rc=$params["rowCount"];

 

if($ps<=0)return "";

 

$pc=ceil($rc/$ps);

 

if($pc<=1)return "";

 

$p="1";

 

if($pc>1)

{

$k=15;

$x=(ceil($pg/$k)-1);

if($pg==1)

$p="<a><font face=webdings>9</font><a> ";

else

$p="<a href=JavaScript:p(1)><font face=webdings>9</font></a> ";

$s=$x*$k+1;

$e=$s+$k;

if($x>0)$p.="<a href=JavaScript:p(".($s-1).")><font face=webdings>7</font></a> ";

if($e>$pc)$e=$pc+1;

for($i=$s;$i<$e;$i++)

{

if($pg==$i)

$p.="<font color=red><b>$i</b></font> ";

else

$p.="<a href=JavaScript:p($i)>$i</a> ";

}

 

if($pc>$k && $e<$pc)$p.="<a href=JavaScript:p($e)><font face=webdings>8</font></a> ";

 

if($pg==$pc)

$p.="<a><font face=webdings>:</font></a>";

else

$p.="<a href=JavaScript:p($pc)><font face=webdings>:</font></a>";

 

}

$r="<table class=pager width='100%' cellpading=5 cellspacing=0 align=center>";

$r.="<tr><td width=200>Page: $pg/$pc Total $rc</td><td align=right><nobr>$p  </nobr></td></tr>";

$r.="</table>";

 

return $r;

}

?>

 

 

 

how can this be changed alphabetically???

 

anyone can help?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.