Page 3 of 4
Re: parent child information pages
Posted: Sun Mar 13, 2016 3:32 pm
by artcore
I usually use HTTPS_SERVER.'image/'...
If you want to release it, you should wrap it in an ocmod.
Inline css, oh no
Please use addStyle() in your controller to add your custom css file to the head.
If you have more than one level of children, css can be tricky
Enjoy the sun also today, clients can wait

Re: parent child information pages
Posted: Mon Mar 14, 2016 12:24 am
by masterbeta
artcore wrote:I usually use HTTPS_SERVER.'image/'...
If you want to release it, you should wrap it in an ocmod.
Inline css, oh no
Please use addStyle() in your controller to add your custom css file to the head.
If you have more than one level of children, css can be tricky
Enjoy the sun also today, clients can wait

everything is working as expected

- one last hurdle - it's not showing the SEO friendly links.... lol
i had to use inline css since each information page will have a different background - i suppose i could addStyle() it however, i'd have to redo also the tpl - i figure for now, it's working minus the SEO links.... it displays the full .com/index.php...information/information=path=25_25 blah blah instead of .com/InfoFriendlyLink
it's accepting the SEO keyword into the db but returns "information page not found!!" when i manually type .com/InfoFriendlyLink ...
once that is finished i'll add the proper addStyle function

- then i'll need a tutorial to make this whole 'package' an ocmod

Re: parent child information pages
Posted: Mon Mar 14, 2016 12:46 am
by cyclops12
Excellent news....we should expect the ocmod by tonight then
Only joking but well done
Re: parent child information pages
Posted: Mon Mar 14, 2016 12:55 am
by artcore
Each page gets its own css class on the body, maybe you can use that?
See how category seo urls are parsed with their path, you can copy this behavior in common/seo_url.php
But information_id should be enough even with path params. What happens if you add just that in the url_alias column?
Anyway, good job!
Re: parent child information pages
Posted: Mon Mar 14, 2016 3:01 pm
by masterbeta
hmmmm what do you mean to add for the url_alias column?
i'm having troubles with the seo_url.php - as is, i can either make info or cats show friendly links, i've went so far as to duplicate the if statements to use 'path' and 'path2' as well as 'url' and 'url2' (cats, info, respectively) to separate them, but still not working as expected.....
Re: parent child information pages
Posted: Mon Mar 14, 2016 3:58 pm
by artcore
Code: Select all
$children_data[] = array(
'title' => $child['title'],
'href' => $this->url->link('information/information', 'information_id=' . $child['information_id']),
);
And also leave out path in the category href as well, all cats have unique ids anyway.
I'll take a look later on when I'm back on PC.
Re: parent child information pages
Posted: Mon Mar 14, 2016 6:29 pm
by masterbeta
i already have it set up that way with the info id - i believe the problem is with this line:
Code: Select all
return $url_info['scheme'] . '://' . $url_info['host'] . (isset($url_info['port']) ? ':' . $url_info['port'] : '') . str_replace('/index.php', '', $url_info['path']) . $url . $query;
where it spits out the path for cats...
Re: parent child information pages
Posted: Mon Mar 14, 2016 8:04 pm
by masterbeta
here's what i have...
seo:
Code: Select all
<?php
class ControllerCommonSeoUrl extends Controller {
public function index() {
// Add rewrite to url class
if ($this->config->get('config_seo_url')) {
$this->url->addRewrite($this);
}
// Decode URL
if (isset($this->request->get['_route_'])) {
$parts = explode('/', $this->request->get['_route_']);
// remove any empty arrays from trailing
if (utf8_strlen(end($parts)) == 0) {
array_pop($parts);
}
foreach ($parts as $part) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE keyword = '" . $this->db->escape($part) . "'");
if ($query->num_rows) {
$url = explode('=', $query->row['query']);
if ($url[0] == 'product_id') {
$this->request->get['product_id'] = $url[1];
}
if ($url[0] == 'category_id') {
if (!isset($this->request->get['path'])) {
$this->request->get['path'] = $url[1];
} else {
$this->request->get['path'] .= '_' . $url[1];
}
}
if ($url[0] == 'manufacturer_id') {
$this->request->get['manufacturer_id'] = $url[1];
}
/*if ($url[0] == 'information_id') {
$this->request->get['information_id'] = $url[1];
}*/
if ($url[0] == 'information_id') {
if (!isset($this->request->get['information_id'])) {
$this->request->get['information_id'] = $url[1];
} else {
$this->request->get['information_id'] .= '_' . $url[1];
}
}
if ($query->row['query'] && $url[0] != 'information_id' && $url[0] != 'manufacturer_id' && $url[0] != 'category_id' && $url[0] != 'product_id') {
$this->request->get['route'] = $query->row['query'];
}
} else {
$this->request->get['route'] = 'error/not_found';
break;
}
}
if (!isset($this->request->get['route'])) {
if (isset($this->request->get['product_id'])) {
$this->request->get['route'] = 'product/product';
} elseif (isset($this->request->get['path'])) {
$this->request->get['route'] = 'product/category';
} elseif (isset($this->request->get['manufacturer_id'])) {
$this->request->get['route'] = 'product/manufacturer/info';
} elseif (isset($this->request->get['information_id'])) {
$this->request->get['route'] = 'information/information';
}
}
if (isset($this->request->get['route'])) {
return new Action($this->request->get['route']);
}
}
}
public function rewrite($link) {
$url_info = parse_url(str_replace('&', '&', $link));
$url = '';
$data = array();
parse_str($url_info['query'], $data);
foreach ($data as $key => $value) {
if (isset($data['route'])) {
if (($data['route'] == 'product/product' && $key == 'product_id') || (($data['route'] == 'product/manufacturer/info' || $data['route'] == 'product/product') && $key == 'manufacturer_id')) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = '" . $this->db->escape($key . '=' . (int)$value) . "'");
if ($query->num_rows && $query->row['keyword']) {
$url .= '/' . $query->row['keyword'];
unset($data[$key]);
}
} elseif ($key == 'path') {
$categories = explode('_', $value);
foreach ($categories as $category) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = 'category_id=" . (int)$category . "'");
if ($query->num_rows && $query->row['keyword']) {
$url .= '/' . $query->row['keyword'];
} else {
$url = '';
break;
}
}
unset($data[$key]);
} elseif ($key == 'information_id') {
$informations = explode('_', $value);
foreach ($informations as $information) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = 'information_id=" . (int)$information . "'");
if ($query->num_rows && $query->row['keyword']) {
$url .= '/' . $query->row['keyword'];
} else {
$url = '';
break;
}
}
unset($data[$key]);
}
}
}
if ($url) {
unset($data['route']);
$query = '';
if ($data) {
foreach ($data as $key => $value) {
$query .= '&' . rawurlencode((string)$key) . '=' . rawurlencode((string)$value);
}
if ($query) {
$query = '?' . str_replace('&', '&', trim($query, '&'));
}
}
return $url_info['scheme'] . '://' . $url_info['host'] . (isset($url_info['port']) ? ':' . $url_info['port'] : '') . str_replace('/index.php', '', $url_info['path']) . $url . $query;
} else {
return $link;
}
}
}
header:
Code: Select all
$data['informations'] = array();
$informations = $this->model_catalog_information->getInformations(0);
foreach ($informations as $information) {
if (!$information['bottom']) {
// Level 2
$children_data = array();
$children = $this->model_catalog_information->getInformations($information['information_id']);
foreach ($children as $child) {
$filter_data = array(
'filter_information_id' => $child['information_id'],
'filter_sub_information' => true
);
$children_data[] = array(
'title' => $child['title'],
'href' => $this->url->link('information/information', 'information_id=' . $information['information_id'] . '_' . $child['information_id'])//path2
);
}
// Level 1
$data['informations'][] = array(
'title' => $information['title'],
'children' => $children_data,
'column' => $information['column'] ? $information['column'] : 1,
'href' => $this->url->link('information/information', 'information_id=' . $information['information_id'])//path2
);
}
}
controller information:
Code: Select all
<?php
class ControllerInformationInformation extends Controller {
public function index() {
$this->load->language('information/information');
$this->load->model('catalog/information');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
/* if (isset($this->request->get['information_id'])) {
$information_id = (int)$this->request->get['information_id'];
} else {
$information_id = 0;
} */
if (isset($this->request->post['path'])) {
$data['path'] = $this->request->post['path'];
} elseif (!empty($information_info)) {
$data['path'] = $information_info['path'];
} else {
$data['path'] = '';
}
if (isset($this->request->get['path'])) {//path2
$url = '';
$path = '';//path2
$tts = explode('_', (string)$this->request->get['path']);//path2
$information_id = (int)array_pop($parts);
foreach ($parts as $path_id) { //path_id
if (!$path['path']) {//path2
$path['path'] = (int)$path_id;//path2 path_id
} else {
$path['path'] .= '_' . (int)$path_id;//path2 path_id
}
$information_info = $this->model_catalog_information->getInformation($path_id); //path_id
if ($information_info) {
$data['breadcrumbs'][] = array(
'text' => $information_info['title'],
'href' => $this->url->link('information/information', 'information_id=' . $path . $url) //path2
);
}
}
} else {
$information_id = 0;
}
$information_info = $this->model_catalog_information->getInformation($information_id);
if ($information_info) {
$this->document->setTitle($information_info['meta_title']);
$this->document->setDescription($information_info['meta_description']);
$this->document->setKeywords($information_info['meta_keyword']);
$data['heading_title'] = $information_info['title'];
$data['button_continue'] = $this->language->get('button_continue');
$data['breadcrumbs'][] = array(
'text' => $information_info['title'],
'href' => $this->url->link('information/information', 'information_id=' . $this->request->get['path'])//path2
);
$this->load->model('tool/image');
if ($information_info['image']) {
$data['thumb'] = $information_info['image'];
} else {
$data['thumb'] = '';
}
$data['description'] = html_entity_decode($information_info['description'], ENT_QUOTES, 'UTF-8');
$url = '';
$data['informations'] = array();
$results = $this->model_catalog_information->getInformations($information_id);
foreach ($results as $result) {
$filter_data = array(
'filter_information_id' => $result['information_id'],
'filter_sub_information' => true
);
$data['informations'][] = array(
'title' => $result['title'],
'href' => $this->url->link('information/information', 'information_id=' . $this->request->get['path'] . '_' . $result['information_id'] . $url)//path2
);
}
$url = '';
$data['continue'] = $this->url->link('common/home');
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/information/information.tpl')) {
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/information/information.tpl', $data));
} else {
$this->response->setOutput($this->load->view('default/template/information/information.tpl', $data));
}
} else {
$url = '';
if (isset($this->request->get['path'])) {//path2
$url .= '&information_id=' . $this->request->get['path'];//path2
}
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_error'),
//'href' => $this->url->link('information/information', 'information_id=' . $information_id)
'href' => $this->url->link('information/information', $url)
);
$this->document->setTitle($this->language->get('text_error'));
$data['heading_title'] = $this->language->get('text_error');
$data['text_error'] = $this->language->get('text_error');
$data['button_continue'] = $this->language->get('button_continue');
$data['continue'] = $this->url->link('common/home');
$this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found');
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/error/not_found.tpl', $data));
} else {
$this->response->setOutput($this->load->view('default/template/error/not_found.tpl', $data));
}
}
}
public function agree() {
$this->load->model('catalog/information');
/*if (isset($this->request->get['information_id'])) {
$information_id = (int)$this->request->get['information_id'];
} else {
$information_id = 0;
} */
if (isset($this->request->get['path'])) {//path2
$url = '';
$path = '';//path2
$parts = explode('_', (string)$this->request->get['path']);//path2
$information_id = (int)array_pop($parts);
foreach ($parts as $path_id) {//path_id
if (!$path['path']) {//path2
$path['path'] = (int)$path_id;//path2 path_id
} else {
$path['path'] .= '_' . (int)$path_id;//path2 path_id
}
$information_info = $this->model_catalog_information->getInformation($path_id); //path_id
if ($information_info) {
$data['breadcrumbs'][] = array(
'text' => $information_info['title'],
'href' => $this->url->link('information/information', 'information_id=' . $path . $url)//path2
);
}
}
} else {
$information_id = 0;
}
$output = '';
$information_info = $this->model_catalog_information->getInformation($path_id);
if ($information_info) {
$output .= html_entity_decode($information_info['description'], ENT_QUOTES, 'UTF-8') . "\n";
}
$this->response->setOutput($output);
}
}
either my controller info is fcked up or the line in the seo?
Re: parent child information pages
Posted: Mon Mar 14, 2016 9:24 pm
by artcore
It did something similar for an ext of mine and just used parent_id to get a hierarchy. So no path anywhere.
It's in my sig -> documents & downloads -
public cats with children have a submenu onpage(not in menu yet, maybe later:))
http://demo.ilithemes.com/oc2031/index. ... egory_id=5
I see you're still using path in the url so you either follow the oc category logic or drop it completely.
I'm actually not sure what the advantage of having a path is anyway, maybe for breadcrumbs.
If you want to have say four levels your path would be like 1_2_3_4
I don't like this
I'm building a menu for an upcoming ext as of today and decided to use a module that I can just echo in the oc menu.
Thought I do this first so I can think with you
So a one liner ocmod
I have it on an information page just for testing and debugging
http://demo.ilithemes.com/oc2031/index. ... ation_id=4
On the tpl it's just an echo $dd_menu;
I don't know how to get the levels in uls and lis yet. Maybe using array index count as level.
Unfortunately my parents in law came by

so it'll be tomorrow
grrrr
Re: parent child information pages
Posted: Tue Mar 15, 2016 3:27 am
by masterbeta
yes i tried using 'path' ,'path2', 'information_id' , 'information_info['path'], etc.... - the path_id is equal to parent_id but the 'path' is what oc uses to generate the child pages for seo keywords/friendly links
what happened to the good old days of simple mod_rewrite for pretty links and using the page title as the "keyword" lol
i even removed all path calls for information pages to just keep it information_id the way it normally reads/rewrites the links and still no good...
i've been backwards debugging and found that either the controller is goofy or the line of path in the seo file...
i'll work on it some more to see what happens...
getting close!
hi to the in-laws!

Re: parent child information pages
Posted: Tue Mar 15, 2016 4:31 am
by masterbeta
figured it out finally
now onto testing! working great so far
where is that ocmod tutorial now? lol
Re: parent child information pages [SOLVED] :D
Posted: Tue Mar 15, 2016 5:52 am
by artcore
masterbeta -> masterrelease
So what was it?
Re: parent child information pages [SOLVED] :D
Posted: Tue Mar 15, 2016 5:54 am
by cyclops12
Yay, well done can't wait to see it working
Re: parent child information pages [SOLVED] :D
Posted: Tue Mar 15, 2016 5:12 pm
by masterbeta
artcore wrote:masterbeta -> masterrelease
So what was it?
i forgot to hook up the doll...
lol
the controller was botched, so i scrapped it, started from scratch, rewrote it, and now it's perfetto
cyclops12 wrote:Yay, well done can't wait to see it working
you will soon! should i seriously turn it into an ocmod? or just simply zip up the files or post the code here?
Re: parent child information pages [SOLVED] :D
Posted: Tue Mar 15, 2016 5:53 pm
by artcore
I say create a module so you can just echo it in the header or footer or anywhere you feel like
controller>module>information_menu.php
Add all your custom stuff from header controller in here
End with
return $this->load->view('default/template/module/info_menu.tpl',$data);
module folder>info_menu.tpl
html markup with data
OCMOD 2 files[/]
In header controller
$data['info_menu'] = $this >load->controller(module/information_menu)
In header tpl: echo $info_menu; at a nice spot 
Minimum core changes FTW
Re: parent child information pages [SOLVED] :D
Posted: Tue Mar 15, 2016 9:22 pm
by artcore
Re: parent child information pages [SOLVED] :D
Posted: Wed Mar 16, 2016 2:35 am
by cyclops12
@artcore, i just checked your nest and its not quite inline see below...
art-nest.png (10.18 KiB) Viewed 2285 times
Plus as there are gaps between the nests if you scroll the mouse down slowly you loose focus and the dropdown dissappears and you have to hover back over Documents again to show it.
Sorry dont take this the wrong way, just making observations

Re: parent child information pages [SOLVED] :D
Posted: Wed Mar 16, 2016 2:46 am
by artcore
That's the old CSS cached in your browser

Guess I can add ?v=1 to the css link to force the browser to get the latest.
If you refresh it'll be better. I still need to add some carets so people know it has a submenu.
BTW it's in the oc main menu now. It's off on the page itself due to oc changing the bootstrap markup and the module has to be echoed in the menu anyway.
Thanks for reporting though

Re: parent child information pages [SOLVED] :D
Posted: Wed Mar 16, 2016 2:49 am
by cyclops12
Ahh yes thats cool i like that, well done
Re: parent child information pages [SOLVED] :D
Posted: Wed Mar 16, 2016 6:00 pm
by artcore
Thanks
