What’s your vision for this module with regards to the 2.0 release? I was really hoping 2.0 would support this exact sort of feature (something to break out of the templateGroup/template) mold, but after watching the 2.0 screen casts, it doesn’t appear to offer any huge paradigm changes.
I’m looking forward to seeing your screen casts…
I needed a function similar to nav_sub but for the entire page structure. I’ve made a new function based on the nav_sub function. It expects your homepage to have / as structure URI with {exp:structure:nav_main} you can generate nested UL’s, put the code in mod.structure.php
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("/", $site_pages['uris']);
// get node of the current entry
$node = 0; //$start_node = $entry_id ? $this->nset->getNode($entry_id) : false;
// node does not have any structure data we return nothing to prevent errors
if ($node === false && ! $entry_id) {
return '';
}
// if we have an entry id but no node, we have listing entry
if ($entry_id && ! $node) {
// get entry's parent id
$pid = $this->get_pid_for_listing_entry($entry_id);
// get node of parent entry
// because we will be showing nav sub from its view point
$node = $start_node = $this->nset->getNode($pid);
}
// if we are on a root that is a leaf
// no sub nav to return
if ($node && $node['isLeaf'] && $node['depth'] == 0) {
return '';
}
if ($node['isLeaf'] && $node['depth'] > 1) {
// we are on a child leaf past the root level
// so we use the parent as the starting point for the sub nav
$start_node = $this->nset->getNode($node['parent_id']);
}
//print_r($start_node);die;
// get siblings
$where = 'node.parent_id = ' . ($start_node['depth'] ? $start_node['parent_id'] : $start_node['id']);
// get children
$where .= ' OR node.parent_id = ' . $start_node['id'];
$entry_depth = $start_node['depth'] ? $start_node['depth'] : 1;
// get structure data from DB
$sql = "SELECT node.*,
(COUNT(parent.entry_id) - 1) AS depth,
((COUNT(parent.entry_id) - 1) - $entry_depth) AS subDepth,
if((node.rgt - node.lft) = 1,1,0) AS isLeaf,
expt.title
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 parent.lft > 1
GROUP BY node.entry_id
ORDER BY node.lft";
$result = $DB->query($sql);
// check how many entries at subDepth 0
$num = 0;
foreach ($result->result as $entry) {
if ($entry['subDepth'] == 0) {
$num++;
}
}
// if we only have 1 subDepth 0 entry and it has children
// then we just show the children
if ($num === 1 && $result->num_rows > 1) {
unset($result->result[0]);
foreach ($result->result as &$entry) {
$entry['subDepth'] -= 1;
}
}
$html = '<ul id="nav_main">';
$prev_subDepth = false;
$ul_open = false;
$i= 0;
foreach ($result->result as $entry) {
if($prev_subDepth == $entry["subDepth"] AND $prev_subDepth != false){
$html .= "</li>";
}
if($entry["subDepth"] > $prev_subDepth and $i >0){
$html .= '<ul>';
}
if($entry["subDepth"] < $prev_subDepth and $i >0){
$x = $prev_subDepth - $entry["subDepth"];
for($y=0;$y<$x;$y++){
$html .= '</li></ul>';
}
}
// out entry uri of this loop instance
$euri = $site_pages['uris'][$entry['entry_id']];
// current page's parent uri
$puri = $node['parent_id'] ? $site_pages['uris'][$node['parent_id']] : '';
$here = '';
if ($euri === $puri) {
$here = ' parent_here';
} else if ($uri === $euri) {
$here = ' here';
}
$html .= '<li class="sub_level_' . $entry['subDepth'] . $here . '">';
$html .= '<a href="http://">' . $entry['title'];_ $html .= '</a>';
$prev_subDepth = (int)$entry['subDepth'];
$i++;
}
$html .= '</ul>';
//$html .= '<pre>' . $sql . '</pre>
<p>’;
return $html;
}
I’m trying to get Structure v1.0.1 running on a Plesk 8.2.1 (dv) 3.0 server at Media Temple running PHP 5.2.3 as a binary CGI.
ExpressionEngine works fine, but when trying to enable the Structure extension at CP Home > Admin > Utilities > Extensions Manager, I get the following error message:
Warning: Cannot modify header information - headers already sent by (output started at /path/to/system/extensions/ext.structure_ext.php:1) in /path/to/system/core/core.functions.php on line 296
Since I can’t continue, I hit the back button in my browser and the Extension shows that it’s somehow enabled despite the error!
Oddly, I’m able to access the Structure module/settings and create a new page from the Publish menu, but when submitting the entry the same error message appears. From my research, the error message does not appear if you click “Quick Save” — only when you submit the entry by clicking “Update”.
It seems like the information is being saved to the database, but something I can’t determine is causing the PHP header errors. Is anyone else using Structure with PHP 5 as a CGI and getting these errors? I’m running ExpressionEngine 1.6.4 (20080829) from a fresh installation.
I’m testing this awesome module. On my localhost server everything works well. On my live server can’t load jQuery file. As I analyze source code, there is missing following part of code:
<s*cript type="text/javascript" src="http://website-domain/system/lib/jquery-1.2.6.js"></s*cript>
So AXAJ functionality doesn’t work for me. Could you help me anybody localize the problem?
Quick question about the navigation tags.. is there (going to be) any other params that can be used? Such as a way to generate the list for the top-level items as well (not just the child items), and to restrict it to a single level rather than the two levels?
On a somewhat related note, I’ve written a pretty simple plug-in that will return the first level of children (if there are any) for a specific entry, in the order specified by the “Structure” module. If anyone’s interested, I can make it available.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.