Post by masterbeta » Wed Jan 27, 2016 1:40 pm

so i'd like to setup a parent/child set of information pages - i tried searching the forums but i only get 1.4/1.5 extensions that are outdated and not for 2.xx - plus, seems a bit pricey

i've managed to create a simple menu of information pages by simply adding this to the array:

Code: Select all

$data['informations2'] = array();

		foreach ($this->model_catalog_information->getInformations() as $result) {
			if (!$result['bottom']) {
				$data['informations2'][] = array(
					'title' => $result['title'],
					'href'  => $this->url->link('information/information', 'information_id=' . $result['information_id'])
				);
			}
		}
where now in header tpl file i can call all the information pages i've NOT selected to show on 'bottom' by using "$informations2" - this works nicely as now my information pages show up nicely in the 'category' navbar.... however, i do not want all information pages showing on bar and would rather have a parent/child relationship

so for example info1parent | info2parent
and under info1child, info1child2 | info2child, info2child2, info2child3

instead of info1 | info2 | info3 | etc....

anyone recommend a way to do this?
i'd like to set parent/child in admin section as well...

thanks in advance!
Last edited by masterbeta on Tue Mar 15, 2016 5:14 am, edited 1 time in total.

New member

Posts

Joined
Thu Nov 26, 2015 3:55 pm
Location - Ikaria, Greece

Post by daniGo » Wed Jan 27, 2016 2:43 pm

Look how category working and copy it. Db tables and files.

http://www.gombac.si


Active Member

Posts

Joined
Wed Mar 20, 2013 4:49 pm
Location - Slovenia

Post by masterbeta » Fri Jan 29, 2016 8:45 pm

yes i see all that - i was hoping someone already has done this and perhaps share the code?

thanks

New member

Posts

Joined
Thu Nov 26, 2015 3:55 pm
Location - Ikaria, Greece

Post by masterbeta » Mon Feb 15, 2016 4:23 pm

so does anyone have a fix for this?

very tedious to alter the information controllers...

New member

Posts

Joined
Thu Nov 26, 2015 3:55 pm
Location - Ikaria, Greece

Post by masterbeta » Sat Feb 27, 2016 2:23 pm

anyone anyone?

New member

Posts

Joined
Thu Nov 26, 2015 3:55 pm
Location - Ikaria, Greece

Post by artcore » Sat Feb 27, 2016 3:21 pm

Why not use any of the free blog extensions? Worst case, you can learn how to setup the logic as it's the same thing.

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by masterbeta » Sat Feb 27, 2016 7:41 pm

artcore wrote:Why not use any of the free blog extensions? Worst case, you can learn how to setup the logic as it's the same thing.
because that's just a brilliant idea i haven't thought of ;) lol

thank you! - i've downloaded 2 to test out and see what happens....

if anyone interested, i'll repost with results

New member

Posts

Joined
Thu Nov 26, 2015 3:55 pm
Location - Ikaria, Greece

Post by artcore » Sat Feb 27, 2016 8:42 pm

Lol :D
Related tips for googling are php sql parent-child, recursive menu function and multidimensional array menu.
Goodluck!

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by masterbeta » Wed Mar 09, 2016 11:21 pm

ok so i have everything working except for the admin form page of information in the "Parent" box the autocomplete feature doesn't seem to be working correctly.... basically just says --NONE-- so that tells me it's not truly reading the database variables for the titles to populate this specific entry....
i can go into the database and edit the parent/child relationship and it shows on admin side - but i'd like to admin-side administrate things, not in the database.... - no errors either...

what am i missing??

any advice?

thanks in advance! :D

ps. i did not use any extension as all the ones seem not to do what i want it to do... basically i copied most of categories files into the information files, etc etc... including the db tables

New member

Posts

Joined
Thu Nov 26, 2015 3:55 pm
Location - Ikaria, Greece

Post by artcore » Thu Mar 10, 2016 12:22 am

It seems your only missing the ajax results then, nice job!
Setup a function in your controller that returns a json object from the db. You can use the same function for getting all categories. An example is in the product controller. It ends with addHeader:json....
In the tpl you have your javascript ajax function that on success updates the dropdown list. All magic is done with jQuery's autocomplete so it should be fairly easy to implement.
Again similar to the product_form.tpl in admin.

Just make sure all selectors are correct, like input[name=...] so this gets updated with the cat name after clicking the selection from the dropdown.
It's bit of a puzzle but once you get the logic it's easy ;D

I'll post an example when I'm back on the PC

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by masterbeta » Thu Mar 10, 2016 5:06 am

artcore wrote:It seems your only missing the ajax results then, nice job!
Setup a function in your controller that returns a json object from the db. You can use the same function for getting all categories. An example is in the product controller. It ends with addHeader:json....
In the tpl you have your javascript ajax function that on success updates the dropdown list. All magic is done with jQuery's autocomplete so it should be fairly easy to implement.
Again similar to the product_form.tpl in admin.

Just make sure all selectors are correct, like input[name=...] so this gets updated with the cat name after clicking the selection from the dropdown.
It's bit of a puzzle but once you get the logic it's easy ;D

I'll post an example when I'm back on the PC
awesome!!! :D - and thanks! :D - i will take a look now to see - i'm so excited i may even touch myself tonight...

lol

New member

Posts

Joined
Thu Nov 26, 2015 3:55 pm
Location - Ikaria, Greece

Post by masterbeta » Thu Mar 10, 2016 5:28 am

well this is what i already have in the controller for the autocomplete...

Code: Select all

public function autocomplete() {
		$json = array();

		if (isset($this->request->get['filter_name'])) {
			$this->load->model('catalog/information');

			$filter_data = array(
				'filter_name' => $this->request->get['filter_name'],
				'sort'        => 'title',
				'order'       => 'ASC',
				'start'       => 0,
				//'limit'       => 5
			);

			$results = $this->model_catalog_information->getInformations($filter_data);

			foreach ($results as $result) {
				$json[] = array(
					'information_id' => $result['information_id'],
					'title'        => strip_tags(html_entity_decode($result['title'], ENT_QUOTES, 'UTF-8'))
				);
			}
		}

		$sort_order = array();

		foreach ($json as $key => $value) {
			$sort_order[$key] = $value['title'];
		}

		array_multisort($sort_order, SORT_ASC, $json);

		$this->response->addHeader('Content-Type: application/json');
		$this->response->setOutput(json_encode($json));
	}
and in the form:

Code: Select all

 <script type="text/javascript"><!--
$('input[name=\'path\']').autocomplete({
	'source': function(request, response) {
		$.ajax({
			url: 'index.php?route=catalog/information/autocomplete&token=<?php echo $token; ?>&filter_name=' +  encodeURIComponent(request),
			dataType: 'json',
			success: function(json) {
				json.unshift({
					information_id: 0,
					title: '<?php echo $text_none; ?>'
				});

				response($.map(json, function(item) {
					return {
						label: item['title'],
						value: item['information_id']
					}
				}));
			}
		});
	},
	'select': function(item) {
		$('input[name=\'path\']').val(item['label']);
		$('input[name=\'parent_id\']').val(item['value']);
	}
});
//--></script> 
  <script type="text/javascript"><!--
$('#language a:first').tab('show');
//--></script>
but it only spits out the --NONE--

the product controller and form, look similar.... and i added both to see, but still returns --NONE--

New member

Posts

Joined
Thu Nov 26, 2015 3:55 pm
Location - Ikaria, Greece

Post by artcore » Thu Mar 10, 2016 5:48 am

So you have a hierachy in the information pages or do you have also setup categories?
You're calling the info pages using oc's function. If you have any pages in the db it should spit out results.
Time to debug. Check the browser dev tools or firebug and check the XHR tab. Whta's the json return say?
You have to verify from the lowest step and then the next to see if the desired result is coming and work from there...until you're done ;D

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by masterbeta » Thu Mar 10, 2016 6:34 am

browser dev on xhr returns: [ ]

no errors, no debug info either...

i'm wondering either if the html strip tags is affecting the 'title' from the db or perhaps i have an error somewhere - time for sleep here will work on it more tomorrow and see what happens....
:D

thanks again for all the help so far!

New member

Posts

Joined
Thu Nov 26, 2015 3:55 pm
Location - Ikaria, Greece

Post by kirkhall » Thu Mar 10, 2016 10:22 am

I don't mean to barge in but...
I needed this same thing in 1.5.6.4 version and just used categories and sub cats and hid the things I did not want on those pages using .css about a year ago. It works but I would have rather done and still want to do what you are trying to achieve here or buy an extension that does same. I'm currently working on an upgrade of the site to some 2.X version. Maybe you could offer your solution up in the extension store? maybe? I'm kind of surprised that an extension does not already exist. I guarantee at least one sale if it works.

Active Member

Posts

Joined
Thu May 22, 2014 11:31 am

Post by masterbeta » Thu Mar 10, 2016 2:52 pm

kirkhall wrote:I don't mean to barge in but...
I needed this same thing in 1.5.6.4 version and just used categories and sub cats and hid the things I did not want on those pages using .css about a year ago. It works but I would have rather done and still want to do what you are trying to achieve here or buy an extension that does same. I'm currently working on an upgrade of the site to some 2.X version. Maybe you could offer your solution up in the extension store? maybe? I'm kind of surprised that an extension does not already exist. I guarantee at least one sale if it works.
no worries it's a public forum :D

i'm just surprised this wasn't implemented from the get go.... the information pages and categories pages code is nearly identical.... all i basically did was open each file (total of 14 files if i remember correctly) and compared.... then i copied over from categories into information so that the information pages react sort of in the same fashion as categories, with having a parent id and nesting - on the display side of things, i basically left the information tpls alone (for the most part) - however, since i'm about 99% complete with this - once totally finished, i will submit the code so everyone can have a cms-type information pages layout system with hierarchy :) i believe the last piece to my puzzle is this autocomplete json system that's not picking up my parent id info titles for some reason....

New member

Posts

Joined
Thu Nov 26, 2015 3:55 pm
Location - Ikaria, Greece

Post by artcore » Thu Mar 10, 2016 3:28 pm

If you want to find it yourself, you have to do the debugging for every step and verify the expected data.
Or send me all the files in a zip and I'll help you out (but won't write it for you:) ).
btw how are you saving it to the db?

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by masterbeta » Thu Mar 10, 2016 9:18 pm

artcore wrote:If you want to find it yourself, you have to do the debugging for every step and verify the expected data.
Or send me all the files in a zip and I'll help you out (but won't write it for you:) ).
btw how are you saving it to the db?
lol - i do need the help ;)

well, basically i took all the category files (admin/controller, model, view and catalog/controller, model, view) 14 files total if i remember correctly (7 each) - and i compared both files, i noticed information and category are nearly identical except for a few obvious things, so i added over from category into information what was "missing" if you will - on the information db i added all the tables and columns just like category db has - although, in all the files and db i removed any 'filter' and 'column' and 'top' reference (and also in the db for those table/columns, etc) - as my information pages will not need the filter, column, or top functionality (i did not remove the 'filter_data' field in the model files) - i then pieced together what i wanted in a parent/child relationship in the 'information_path' table - so now everything works as expected, i can add information pages, edit, delete, rebuild, etc.... but the Parent json java part isn't working so i can select a parent, basically it's just returning '0' thusly, --NONE-- - i also noticed that if i manually type a parent name in the admin it'll take, but then another time it didn't take (perhaps i misspelled a parent name)

i'm not currently at that computer to send you the files, but when i get back to it, i'll zip everything up and have you take a look if you like....

my server reports no errors, neither does php nor the oc error logs..... i have a feeling i may know what the problem is, but again i won't know until i get back to the files :D

New member

Posts

Joined
Thu Nov 26, 2015 3:55 pm
Location - Ikaria, Greece

Post by masterbeta » Fri Mar 11, 2016 1:39 am

yay i fingered it out!

now it's totally working :)

and yes, i did touch myself earlier

basically the problem was in the admin/model - in the getInformations() there was an if/else statement that was no longer necessary (used on original information scheme, but not this altered one) - so i removed the if/else and commented out the rest - and now it's working brilliantly :D - hence no errors...

now i can go eat

and then work on the menu system for this ;) woohoo header editing next ;)

New member

Posts

Joined
Thu Nov 26, 2015 3:55 pm
Location - Ikaria, Greece

Post by burrito » Fri Mar 11, 2016 2:23 am

not trying to be an ass... but I have a mod that does very much this.
click

it's a little bit different because I'm using seperate categories (has to do with template options for these 'parents')

Image
Opencart specialist | Our website | Our modules


User avatar
Active Member

Posts

Joined
Tue Dec 15, 2009 6:10 pm
Location - Amsterdam, The Netherlands
Who is online

Users browsing this forum: No registered users and 267 guests