Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Дополнение к $wa->site->pages #212

Open
fedoric opened this issue Jul 18, 2017 · 0 comments
Open

Дополнение к $wa->site->pages #212

fedoric opened this issue Jul 18, 2017 · 0 comments

Comments

@fedoric
Copy link

fedoric commented Jul 18, 2017

Здравствуйте. Сейчас конструкция {$pages = $wa->site->pages(null, true)} ограничивает возможности вывода определенного поселения сайт на страницы других приложений , а также вывода нескольких меню разных поселений - только самое верхнее.

Предлагаю внедрить третью переменную {$pages = $wa->site->pages(null, true, null)} которая отвечала бы за вывод определенного поселения.

например {$pages = $wa->site->pages(null, true, 1)}- для первого поселения.

Прилагаю измененный код siteViewHelper.class.php

getByName(waSystem::getInstance()->getRouting()->getDomain(null, true)); $page_model = new sitePageModel(); $sql = "SELECT id, parent_id, name, title, full_url, url, create_datetime, update_datetime FROM ".$page_model->getTableName().' WHERE domain_id = i:domain_id AND route = s:route AND status = 1 ORDER BY sort'; if (!ifset($i)){ $route = wa()->getRouting()->getRoute('url'); $url = $this->wa->getAppUrl(null, true); } else { $routes = wa()->getRouting()->getByApp('site', $domain['name']); if ($routes) { $route = $routes[$i]; $route = $route['url']; $url = wa()->getRootUrl(false, true).waRouting::clearUrl($route); } else { return array(); } } $pages = $page_model->query($sql, array( 'domain_id' => $domain['id'], 'route' => $route) )->fetchAll('id'); if ($with_params) { $page_params_model = new sitePageParamsModel(); $data = $page_params_model->getByField('page_id', array_keys($pages), true); foreach ($data as $row) { $pages[$row['page_id']][$row['name']] = $row['value']; } } foreach ($pages as &$page) { $page['url'] = $url.$page['full_url']; if (!isset($page['title']) || !$page['title']) { $page['title'] = $page['name']; } foreach ($page as $k => $v) { if ($k != 'content') { $page[$k] = htmlspecialchars($v); } } } unset($page); // make tree foreach ($pages as $page_id => $page) { if ($page['parent_id'] && isset($pages[$page['parent_id']])) { $pages[$page['parent_id']]['childs'][] = &$pages[$page_id]; } } if ($parent_id) { return isset($pages[$parent_id]['childs']) ? $pages[$parent_id]['childs'] : array(); } foreach ($pages as $page_id => $page) { if ($page['parent_id'] && $page_id != $parent_id) { unset($pages[$page_id]); } } return $pages; } catch (Exception $e) { return array(); } } public function page($id) { $page_model = new sitePageModel(); $page = $page_model->getById($id); $page['content'] = $this->wa->getView()->fetch('string:'.$page['content']); $page_params_model = new sitePageParamsModel(); $page += $page_params_model->getById($id); return $page; } } Ну и для наглядности и удобства конечного пользователя заменить строчку в Routing.html добавив тем самым визуальное отображение номера поселения. id={$route_id} {$url}/{$route.url|escape|truncate:30:'...':false:true}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant