Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: [SMARTY] this mysql query with smarty
The template only needs to know how to display the items, not what the
parent/child relationship is. So, assign them in the order you want them
displayed, and give each an indent value. Then Smarty just loops through
the values and indents each one.

Something like:

$menu_data = array([0] => array('name' => 'item1', indent => 1),
[1] => array('name' => 'item2', indent => 1),
[2] => array('name' => 'item2.1', indent => 2),
[3] => array('name' => 'item2.2', indent => 2),
[4] => array('name' => 'item3', indent => 1)
[5] => array('name' => 'item3.1', indent => 2),
[6] => array('name' => 'item3.1.1', indent => 3),
);

Then assign & loop over it in the template (untested):

{section name=menu loop=$menu_data}
{section name=foobar
loop=$menu_data[menu].indent} {/section}{$menu_data&#
91;menu].name}<br>
{/section}

I'm using {section} as a repeating loop here, This could be simplified
with a block function or modifier.

On Tue, 2004-03-16 at 13:11, dr. zoidberg wrote:
> Hello,
>
> $a = mysql_query("Select a,b FROM t WHERE category=1")
> while($a) {
> $x = $a[a];
> //some echo
> //another query
>
> $b = mysql_query("Select * FROM t WHERE subcategory=$x")
> while ($b) {
> //some echo
> }
> }
>
> Poent is thet I have menus, parents with childes (childes are not
> parents) and I want to display them in smarty like this:
>
> - Parent 1
> -- Child 1
> -- Child 2
> - Patent 2
> -- Child 3
>
> Child have subid that is parent id.
>
> TNX
>
> --
> Please do not CC me.

Report this thread to moderator Post Follow-up to this message
Old Post
Monte Ohrt
03-19-04 06:29 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Smarty Templates archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:05 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.