Skip to content

Instantly share code, notes, and snippets.

@asjustas
Created March 5, 2014 09:05
Show Gist options
  • Save asjustas/9363729 to your computer and use it in GitHub Desktop.
Save asjustas/9363729 to your computer and use it in GitHub Desktop.
<?php
global $gCms;
$db = &$gCms->GetDb();
$parent = $params['parent'];
if ((int)$parent < 1) {
echo 'nera parent id';
} else {
function __get_parents($db, $parent) {
$arr = array();
$query ="SELECT * FROM `".cms_db_prefix()."content` WHERE `parent_id` = {$parent} AND active = 1 ORDER BY item_order ASC";
$dbresult = $db->Execute($query);
while ($dbresult && $row = $dbresult->FetchRow()) {
$query2 = "SELECT * FROM ".cms_db_prefix()."content_props WHERE content_id = {$row['content_id']} AND prop_name = 'content_en'";
$dbresult2 = $db->Execute($query2);
if ($content = $dbresult2->FetchRow()) {
$row['content'] = $content['content'];
}
$arr[] = $row;
}
return $arr;
}
$result = array();
$query ="SELECT * FROM `".cms_db_prefix()."content` WHERE `parent_id` = {$parent} AND active = 1 ORDER BY item_order ASC";
$dbresult = $db->Execute($query);
while ($dbresult && $row = $dbresult->FetchRow()) {
$item = array(
'name' => $row['menu_text'],
'content_id' => $row['content_id'],
'parents' => __get_parents($db, $row['content_id'])
);
$result[] = $item;
}
$smarty->assign('contacts_page', $result);
/*echo '<pre>';
print_r($result);*/
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment