@travis - This is really an amazing module its come just in the nick of time for a projects I’m on. Thanks again! 😊
Now, my php skills aren’t really my strong point (more of a front end developer) but I had similar needs to what Michael is requesting (ie a top-level items nav) and managed to make a new function out of your nav_sub in mod_structure.php for a top level nav with drop-down to second level. So I can add {exp:structure:nav_main} to get a list with children.
Would you like to see if this is useful for you to add for others to use?
@blis
Here you go… like I say PHP ain’t my strong point so this can probably be improved. But I managed to make this out of the nav_sub function.
Paste into mod_structure.php then just add - {exp:structure:nav_main} to your templates.
Hope this helps 😊
function nav_main() {
global $DB, $IN, $PREFS;
// get site pages data
$site_pages = $PREFS->core_ini['site_pages'];
// get current uri path
$uri = $IN->URI;
// get current entry id
$entry_id = array_search($uri, $site_pages['uris']);
// get node of the current entry
$sql = "SELECT *
FROM exp_structure AS node
INNER JOIN exp_structure AS parent
ON node.lft BETWEEN parent.lft AND parent.rgt
INNER JOIN exp_weblog_titles AS expt
ON node.entry_id = expt.entry_id
WHERE node.parent_id = 0
GROUP BY node.entry_id
ORDER BY node.lft";
$result = $DB->query($sql);
$html = '<ul id="nav">';
foreach ($result->result as $top) {
// get children
$childsql = "SELECT *
FROM exp_structure AS node
INNER JOIN exp_structure AS parent
ON node.lft BETWEEN parent.lft AND parent.rgt
INNER JOIN exp_weblog_titles AS expt
ON node.entry_id = expt.entry_id
WHERE node.parent_id = " .$top['entry_id'] ."
GROUP BY node.entry_id
ORDER BY node.lft";
$childresult = $DB->query($childsql);
// out entry uri of this loop instance
$euri = $site_pages['uris'][$top['entry_id']];
$html .= '<li>';
$html .= '<a href="http://{path=/">' . $top['title'];_ $html .= '</a>';
if ($childresult ->num_rows > 0){
$html .= '<ul>';
foreach ($childresult->result as $child) {
$childuri = $site_pages['uris'][$child['entry_id']];
$html .= '<li><a href="{path=/' . $childuri . '}">' . $child['title'] . '</li>';
}
$html .= '</ul>';
}
$html .= '</li>';
}
$html .= '</ul>';
//$html .= '<pre>' . $childsql . '</pre>
<p>’;
return $html;
}
Pagination currently doesn’t work with the module because we’re assigning exact URLs to entries, so pagination can’t find itself (if that makes sense). On the wishlist. Also, you don’t need dynamic=”off” or it may not work. You only need dynamic=”off” when calling a listing or single entry NOT related to the “page” you’re on.
I’ve just started using it, and so far, I’m really impressed. But I’ve run into one issue that I can’t quite seem to work out.
I have created a weblog entitled “pages” that holds all of my site’s static pages. I’ve created an entry – “Ministries” – that will serve as the “parent” page of the “Ministries” section, and I’ve created several “children” entries – e.g., “Worship”, “Children” – that will be “sub” pages of “Ministries”.
So far, so good. However, I have all of these static pages using a single template. Which means that, when I attempt to pull up “Ministries” or any of its children, I don’t get just that particular entry, I get a list of all of the entries in the “pages” weblog. Which, obviously, isn’t right.
So, what am I doing wrong? Is there some configuration setting I missed?
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.