Re: [SMARTY] Re: Nested queries/nested arrays

Amanda Hemmerich <[email protected]>
Newsgroups gmane.comp.php.smarty.general
Organization Center for Genomics and Bioinformatics
Message-ID <[email protected]>

Matthew Weier O'Phinney wrote:

>If you continue to have problems, you should probably create a dump of
>the DB schema and then post a link to that and the PHP source you're
>working with -- at this point, the suggestions myself and others have
>made should give you something to work with, but there are many
>assumptions we're having to make -- what DB abstraction layer you're
>using, where files are located, etc.
>  
>
Thanks, everyone, for your help so far.

I am no longer getting any errors, but I'm also not getting the data I 
expect, either.

I'm not sure how to create a dump of the DB schema, but I did an export 
from mysql and have the file available:

http://people.cgb.indiana.edu/ahemmeri/test/cgb_tmp.sql

I have attached the .tpl and .php files I am using. 

As for where the files are located, index.php is at the top level and 
calls php code from /includes/code/welcome.php.  The template files are 
in /templates/welcome/index.tpl.

The problem I am having now is that I am not getting the information I 
thought I should have, which is an array of arrays with the project 
information with the projects that have sub-projects having an 
additional array of sub-project info. 

When I do  print_r($projects), it prints out the array of project stuff, 
however, there is no sub-project array in the array.  The two projects 
with sub projects have the same structure as those with no sub 
projects.  Here is an example of two projects, one with a sub project, 
one without:

Array ( [1] =>

(this one has no sub projects)
Array ( [0] => CATPA [1] => Curation Analysis Tool for Protein 
Alignments [2] => [3] => As the genomes of more organisms become fully 
sequenced, there will be a greater opportunity to understand the 
function, structure, and evolution of genes. Typically, blah, blahblah. 
[4] => 34 [5] => )

(this one has a sub project)
[14] => Array ( [0] => Regulatory Elements [1] => Regulatory Elements 
[2] => [3] => Transcriptional factors regulate gene expressions by 
binding to elements in DNA sequences. These regulatory elements are ofen 
short (about 4-15 nucleotides long), hidden in the background of nearly 
random DNA sequences, which make their identification difficult. blah, 
blahblah. [4] => 0 [5] => )

)

Looks like the structure is:

[14] (project_id) => Array ( [0] => short_name [1] => title [2] 
=>short_description [3] => description [4] => file_id [5] => 
parent_project_cd)

But there is nothing for subs.

When I try to display the subs query, nothing appears, either.

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
index.tpl~ (text/plain, 2.7 KB)
{* $Id: index.tpl,v 1.266 2005/08/15 17:05:19 ahemmeri Exp $ *}


<p>The Center for Genomics and Bioinformatics is a multidisciplinary research center serving the Indiana University Bloomington campus. The CGB carries out independent research in genomics and bioinformatics, collaborates with and/or assists projects developed by IUB faculty, and promotes interdepartmental and interdisciplinary interactions to enhance genomics and bioinformatics at IUB.</p>

<p>The CGB is currently engaged in collaborations with 13 scientists from Biology, Mathematics, and the School of Informatics. Through the newly established <a href="http://ctdrt.bio.nd.edu/
index.php?content=projectinfo.php&projectno=4">Center for Insect
Genomics</a> we are also collaborating with scientists at both Purdue Univesity and the University of Notre Dame. </p>

<p>IUB faculty can seek CGB assistance or explore the potential for future collaborations by 
contacting the  <a href="{$url_prefix}/feedback/1">director</a> or  <a href="{$url_prefix}/feedback/2">deputy director</a>.</p>

<p>Join our <a href="https://lists.cgb.indiana.edu/listinfo/announce/">mailing list</a> to receive announcements regarding upcoming seminars. </p>
<br />


{$query}
<h4>TESTING</h4>
{foreach from=$projects item='entry'}
    <b>{$entry.short_name}</b> - id ({$entry.project_id})<br />
    <ul>
    {foreach from=$entry.subs item='sub'}
        <li>{$sub.short_name} - {$sub.project_id}</li>
    {foreachelse}
        <li>No subs for this project</li>
    {/foreach}
    </ul>
{foreachelse}
    <b>No projects found</b>
{/foreach}
<br />
<br />

	{section name=id loop=$events}
		<h4><a href="/seminars/sort/{$events[id].event_type_id}">{$events[id].name}</a> ({$events[id].weekday}, {$events[id].time|date_format:" %l:%M %p"} - {$events[id].location})</h4>
		{if $events[id].description} {$events[id].description}<br /><br />{/if}
   	<b>Next Meeting:</b> To Be Announced</a>
   	<br /><br /><br />
	{/section}
	
	<br /><br />
	{section name=id loop=$special_events}
		<h4><a href="/seminars/sort/{$special_events[id].event_type_id}">{$special_events[id].name}</a> </h4>
		{if $special_events[id].category_description} {$special_events[id].category_description}<br /><br />{/if}
   		<b>{$special_events[id].date|date_format:"%A, %B %e, %Y"}, {$special_events[id].time|date_format:" %l:%M %p"}</b> - {$special_events[id].building} {$special_events[id].room}<br />
   		{$special_events[id].speaker} - 
   		<a class="menulink" href="{$url_prefix}/seminars/{$special_events[id].event_id}">{$special_events[id].title}</a>
   		
   		<br /><br /><br />
	{/section}
<p>
	<a href="{$url_prefix}/seminars/"><img src="{$url_prefix}/images/seminars.png" width="123" height="22" alt="Events Archive>" /></a>
</p>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.