Я не нашел ничего лучше, чем следующий код:
//
//
// Don't look the following code just yet . . .
//
//
// You'll be pulling your hair out of your head. Just read me first.
// Following is a huge SQL query, that assume that pages are not nested
// than 9 times. This is actually a hard limitation of EE, and I'm using
// that to get the information I need in only one query instead of nine.
//
// The following code is just to get the path of the current entry we are
// editing, so the redirect page will know where to redirect. And I did
// not find any function or API to get this information. Too bad.
//
// If you find any solution to that, please answer
// /6053168/expressionengine-kak-poluchit-put-k-stranitse-s-uchetom-ee-entryid-s-pomoschy-plagina-struktury
// it might save other people all the trouble.
// S
//
// P
//
// O
//
// I
//
// L
//
// E
//
// R
// First, we get all the entry_id of all the elements that are parent to
// the current element in the structure table (created by the Structure
// plugin).
$q = $this->EE->db->query(
"SELECT
S1.entry_id AS entry9,
S2.entry_id AS entry8,
S3.entry_id AS entry7,
S4.entry_id AS entry6,
S5.entry_id AS entry5,
S3.entry_id AS entry4,
S7.entry_id AS entry3,
S8.entry_id AS entry2,
S9.entry_id AS entry1
FROM
exp_structure AS S1,
exp_structure AS S2,
exp_structure AS S3,
exp_structure AS S4,
exp_structure AS S5,
exp_structure AS S6,
exp_structure AS S7,
exp_structure AS S8,
exp_structure AS S9
WHERE
S1.entry_id = $entry_id AND
S1.parent_id = S2.entry_id AND
S2.parent_id = S3.entry_id AND
S3.parent_id = S4.entry_id AND
S4.parent_id = S5.entry_id AND
S5.parent_id = S6.entry_id AND
S6.parent_id = S7.entry_id AND
S7.parent_id = S8.entry_id AND
S8.parent_id = S9.entry_id");
// Then, we construct a similar query to get all the url_title attributes
// for these pages.
$path = array();
$sql = array("SELECT" => "SELECT", "FROM" => " FROM", "WHERE" => " WHERE");
$j = 1;
for($i = 1; $i <= 9; ++$i){
$id = $q->row("entry$i");
if($id > 0){
$sql['SELECT'] .= " CT$j.url_title AS title$j,";
$sql['FROM'] .= " exp_channel_titles as CT$j,";
$sql['WHERE'] .= " CT$j.entry_id = $id AND";
$j++;
}
}
$sql['SELECT'] = rtrim($sql['SELECT'], ",");
$sql['FROM'] = rtrim($sql['FROM'], ",");
$sql['WHERE'] = preg_replace("/ AND$/", "", $sql['WHERE']);
$sql = $sql['SELECT'] . $sql['FROM'] . $sql['WHERE'];
$q = $this->EE->db->query($sql);
// Finally, we can construct the path for the current page
$path = "/";
for($i = 1; $i < $j; ++$i){
$path .= $q->row("title$i") . '/';
}
//
// Blood and bloody ashes.
//