I don’t mind sharing at all.
I don’t consider myself an expert at PHP or MySQL, but I can kind of hack my way around it. So please forgive me if this isn’t the cleanest code.
Let’s take a look at the Resume. Basically needed to nest a list of entries (projects done at a job) that was related to each item of a category (jobs). Additionally, having just the titles of the entries was not enough, I also needed fields from those entries. So I had to use some PHP/MySQL code to help me through that:
<div class="ressect"><!-- BEGIN EXPERIENCE SECTION -->
<img src="http://{site_base}images/hrd-experience.gif" />
<br />
<!-- Display entries from the 'resume' weblog that belong to the 'Experience' category -->
{exp:weblog:entries weblog="resume" rdf="off" category="35"}
<div class="job">
<p><strong>{title}</strong></p>
<p>{resExpCompany}</p>
<p>{resExpStartDate}&nbsp;-&nbsp;{resExpEndDate}</p>
{resExpDescription}
<div class="jobThumbnails">
<?php
// Get entry_id and url_title of entries in category
$lbsql="SELECT DISTINCT exp_weblog_titles.entry_id, exp_weblog_titles.url_title
FROM exp_weblog_titles
LEFT JOIN exp_weblog_data ON exp_weblog_titles.entry_id = exp_category_posts.entry_id
LEFT JOIN exp_category_posts ON exp_weblog_titles.entry_id = exp_category_posts.entry_id
LEFT JOIN exp_categories ON exp_category_posts.cat_id = exp_categories.cat_id
WHERE exp_category_posts.cat_id = {resExpAgencyCat}
ORDER BY exp_weblog_titles.entry_date DESC";
$lbresult = mysql_query($lbsql);
$lbnum_rows = mysql_num_rows($lbresult);
$lbcount = 0;
// Dump results into Array
while ($lbrow = mysql_fetch_array($lbresult, MYSQL_ASSOC)) {
$lbArr[] = $lbrow;
}
mysql_free_result($lbresult);
// Get Project Type (field_id_40) and print URL for each project
while ($lbcount < $lbnum_rows) {
$lbentry = $lbArr[$lbcount]["entry_id"];
$lburl = $lbArr[$lbcount]["url_title"];
$lbsql = "SELECT field_id_40
FROM exp_weblog_data
WHERE entry_id = $lbentry";
$lbresult = mysql_query($lbsql);
$lbrow = mysql_fetch_array($lbresult, MYSQL_NUM);
?>
<a href="http://{site_ee}/<?php echo "$lbrow[0]/project/$lburl"; ?>"
onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('
<?php echo "i$lbentry"; ?>','','http://{site_base}project/
<?php echo "$lbentry"; ?>/listimage-over.jpg',1)">
<img src="http://{site_base}project/
<?php echo "$lbentry"; ?>/listimage.jpg" width="78"
height="59" border="0" id="
<?php echo "i$lbentry"; ?>"
name="<?php echo "i$lbentry"; ?>" />
</a>
<?php
// echo "$lbentry/$lbrow[0]/$lburl<br>";
$lbcount++;
}
mysql_free_result($lbresult);
// Reset Array
unset($lbArr);
?>
</div>
</div>
{/exp:weblog:entries}
</div><!--END EXPERIENCE-->
1. EE starts to list each entry in the ‘Jobs’ category.
2. For each entry, PHP retreives and spits out the thumbnail and link for each associated project.
3. EE continues the loop until there are no more entries in the ‘Jobs’ category.
I hope that was clear…