View Single Post
Old 9th May 2013, 02:10
dclardy dclardy is offline
Senior Member
Join Date: Sep 2009
Location: Dallas, TX
Posts: 347
Thanks: 10
Thanked 50 Times in 28 Posts

Originally Posted by till View Post
1) Sure. In the form file you can define which column is used for the value field, this can be the same column that you use for the displayed value.

2) Use the tmpl_loop statement in the template, no need for any manual programming in php.

Thanks. I have it saving the correct information to the database now! Now, I just have to figure out this front page.

I am trying to add a sidebar to the front page that output data from the database.

This is how I envision it working.

Category 1
---Stuff from First Item in Category 1
---Stuff Form Second Item in Category 1
Category 2
---Stuff from First Item in Category 2
---Stuff Form Second Item in Category 2

This is my current index.htm.

<aside id="sidebar" class="login-sidebar">
    {tmpl_loop name='sidebar_records'}

<div id="login-form">
    <div class="box-inner">
        <img title="<tmpl_var name="app_title">" id="logo" alt="<tmpl_var name="app_title">" src="<tmpl_var name='app_logo'>">
                    <td class="title">
                        <label for="username">{tmpl_var name='username_txt'}</label>
                    <td class="input">
                        <input name="username" id="username" value="" size="30" maxlength="255" type="text" class="textInput"  onkeypress="if (event.keyCode && event.keyCode == 13) {submitLoginForm('pageForm'); return false;};" />
                    <td class="title">
                        <label for="passwort">{tmpl_var name='password_txt'}</label>
                    <td class="input">
                        <input name="passwort" id="passwort" value="" size="30" maxlength="255" type="password" class="textInput"  onkeypress="if (event.keyCode && event.keyCode == 13) {submitLoginForm('pageForm'); return false;};" />
        <input type="hidden" name="s_mod" value="login" />
        <input type="hidden" name="s_pg" value="index" />
        <p id="loginbutton">
            <button type="button" class="button" value="{tmpl_var name="add_new_record_txt"}" onclick="submitLoginForm('pageForm');"><span>{tmpl_var name='login_button_txt'}</span></button>
        <p class="powered">Powered by <a href="<tmpl_var name="app_link">" target="_blank"><tmpl_var name="app_title"></a></p>
    <div class="box-bottom">
        <div id="message">
            <tmpl_if name="msg">
                <div id="OKMsg"><p><tmpl_var name="msg"></p></div>
            <tmpl_if name="error">
                <div id="errorMsg">
                    <div class="warning"><tmpl_var name="error"></div>
                    <br /><a href="#" onclick="loadContent('login/password_reset.php');">{tmpl_var name='pw_lost_txt'}</a>
I have added this information to the login module.

$sidebar_records = array();
		$sidebar_query = $app->db->queryAllRecords("SELECT category,title,tpl_ispc_clean_app.desc,image_url,link,target FROM tpl_ispc_clean_app order by sorting ");
		if(is_array($sidebar_query)) {
			foreach($sidebar_query as $side_qry) {
				$sidebar_records[$side_qry['category']] = $side_qry['category'];
				$sidebar_records[$side_qry['title']] = $side_qry['title'];
				$sidebar_records[$side_qry['desc']] = $side_qry['desc'];
				$sidebar_records[$side_qry['image_url']] = $side_qry['image_url'];
				$sidebar_records[$side_qry['link']] = $side_qry['link'];
				$sidebar_records[$side_qry['target']] = $side_qry['target'];

$app->tpl->setVar('sidebar', print_r($sidebar_records));
$app->tpl->setLoop('sidebar_records', $sidebar_records);
I guess that I don't understand loops in the templates because nothing is happening. It is throwing out the error Invalid Loop Structure. Any help would be great!
Reply With Quote