Post by artcore » Fri Mar 11, 2016 2:30 am

Awesome masterbeta ;D
LOL you fingered it out :laugh:

Hey burito that's a coincidence but I think masterbeta is having fun and almost done with his version. Thanks for sharing!

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 burrito » Fri Mar 11, 2016 2:32 am

yeah I figured that... I was hesitating to share the message...
it's fun to work on the code :D

Image
Opencart specialist | Our website | Our modules


User avatar
Active Member

Posts

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

Post by kirkhall » Fri Mar 11, 2016 2:47 am

burrito wrote: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')
That looks good. I guess I did not scroll through all the results when I was looking for similar in the store. It's bookmarked and I will be purchasing it as soon as I get other things done.

Active Member

Posts

Joined
Thu May 22, 2014 11:31 am

Post by masterbeta » Fri Mar 11, 2016 7:03 am

well all the information pages seem to be working flawlessly for creating a structure just like the category side of things

i started working on the menu to display properly - so far i'm showing the entire menu of information that i have NOT checked the "bottom" checkbox.... so the ones checked will only show in bottom footer, and the ones not checked will show on the top menu along side of the actual categories/store/products :) works great so far, i'm now on the last step to show the information page child submenus :)

but now is time for sleep ! see you all tomorrow :D

New member

Posts

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

Post by masterbeta » Sat Mar 12, 2016 1:19 am

ok so now i'm having problems displaying the information pages in the menu.... haha

well, not the pages, but the child pages.... everything seems set up correctly - again no errors - so not sure what is happening.... the menu expands to the drop down but no links are inside it....

i've checked the controller, model, and tpl files of course and everything seems there, not sure what would be causing it.... i went so far as to rename the variables so they don't somehow conflict with the current category variables, but still nothing...

any tips? :D

New member

Posts

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

Post by burrito » Sat Mar 12, 2016 2:50 am

do you have the script you're using? and a link to the page?

Image
Opencart specialist | Our website | Our modules


User avatar
Active Member

Posts

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

Post by masterbeta » Sat Mar 12, 2016 4:04 pm

burrito wrote:do you have the script you're using? and a link to the page?
i'm not using any script - just the base files of oc

New member

Posts

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

Post by artcore » Sat Mar 12, 2016 6:36 pm

Hey mastabeta. You're building the menu array like oc does I suppose. Parent and one child. Or...?
It would be handy to see the code :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 » Sat Mar 12, 2016 7:04 pm

artcore wrote:Hey mastabeta. You're building the menu array like oc does I suppose. Parent and one child. Or...?
It would be handy to see the code :D
yes basically :)

ok hang on a moment while i grab the files ...

New member

Posts

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

Post by masterbeta » Sat Mar 12, 2016 8:28 pm

header controller:

Code: Select all

<?php
class ControllerCommonHeader extends Controller {
	public function index() {
		// Analytics
		$this->load->model('extension/extension');

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

		$analytics = $this->model_extension_extension->getExtensions('analytics');

		foreach ($analytics as $analytic) {
			if ($this->config->get($analytic['code'] . '_status')) {
				$data['analytics'][] = $this->load->controller('analytics/' . $analytic['code']);
			}
		}

		if ($this->request->server['HTTPS']) {
			$server = $this->config->get('config_ssl');
		} else {
			$server = $this->config->get('config_url');
		}

		if (is_file(DIR_IMAGE . $this->config->get('config_icon'))) {
			$this->document->addLink($server . 'image/' . $this->config->get('config_icon'), 'icon');
		}

		$data['title'] = $this->document->getTitle();

		$data['base'] = $server;
		$data['description'] = $this->document->getDescription();
		$data['keywords'] = $this->document->getKeywords();
		$data['links'] = $this->document->getLinks();
		$data['styles'] = $this->document->getStyles();
		$data['scripts'] = $this->document->getScripts();
		$data['lang'] = $this->language->get('code');
		$data['direction'] = $this->language->get('direction');

		$data['name'] = $this->config->get('config_name');

		if (is_file(DIR_IMAGE . $this->config->get('config_logo'))) {
			$data['logo'] = $server . 'image/' . $this->config->get('config_logo');
		} else {
			$data['logo'] = '';
		}

		$this->load->language('common/header');

		$data['text_home'] = $this->language->get('text_home');

		// Wishlist
		if ($this->customer->isLogged()) {
			$this->load->model('account/wishlist');

			$data['text_wishlist'] = sprintf($this->language->get('text_wishlist'), $this->model_account_wishlist->getTotalWishlist());
		} else {
			$data['text_wishlist'] = sprintf($this->language->get('text_wishlist'), (isset($this->session->data['wishlist']) ? count($this->session->data['wishlist']) : 0));
		}

		$data['text_shopping_cart'] = $this->language->get('text_shopping_cart');
		$data['text_logged'] = sprintf($this->language->get('text_logged'), $this->url->link('account/account', '', 'SSL'), $this->customer->getFirstName(), $this->url->link('account/logout', '', 'SSL'));

		$data['text_account'] = $this->language->get('text_account');
		$data['text_register'] = $this->language->get('text_register');
		$data['text_login'] = $this->language->get('text_login');
		$data['text_order'] = $this->language->get('text_order');
		$data['text_transaction'] = $this->language->get('text_transaction');
		$data['text_download'] = $this->language->get('text_download');
		$data['text_logout'] = $this->language->get('text_logout');
		$data['text_checkout'] = $this->language->get('text_checkout');
		$data['text_category'] = $this->language->get('text_category');
		$data['text_all'] = $this->language->get('text_all');
$data['text_phone_code'] = $this->language->get('text_phone_code');


$this->load->model('catalog/information');

		$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'])
				);
			}
		}

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

		foreach ($this->model_catalog_information->getInformations() as $result) {
			if (!$result['bottom']) {
				$data['informations3'][] = array(
					'title' => $result['title'],
					'href'  => $this->url->link('information/information', 'information_id=' . $result['information_id'])
				);
			}
		}

		$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', 'path=' . $information['information_id'] . '_' . $child['information_id'])
					);
				}

				// Level 1
				$data['informations'][] = array(
					'title'     => $information['title'],
					'children' => $children_data,
					//'column'   => $category['column'] ? $category['column'] : 1,
					'href'     => $this->url->link('information/information', 'path=' . $information['information_id'])
				);
			}
		}

$data['text_information'] = $this->language->get('text_information');
		$data['home'] = $this->url->link('common/home');
		$data['wishlist'] = $this->url->link('account/wishlist', '', 'SSL');
		$data['logged'] = $this->customer->isLogged();
		$data['account'] = $this->url->link('account/account', '', 'SSL');
		$data['register'] = $this->url->link('account/register', '', 'SSL');
		$data['login'] = $this->url->link('account/login', '', 'SSL');
		$data['order'] = $this->url->link('account/order', '', 'SSL');
		$data['transaction'] = $this->url->link('account/transaction', '', 'SSL');
		$data['download'] = $this->url->link('account/download', '', 'SSL');
		$data['logout'] = $this->url->link('account/logout', '', 'SSL');
		$data['shopping_cart'] = $this->url->link('checkout/cart');
		$data['checkout'] = $this->url->link('checkout/checkout', '', 'SSL');
		$data['contact'] = $this->url->link('information/contact');
		$data['telephone'] = $this->config->get('config_telephone');

		$status = true;

		if (isset($this->request->server['HTTP_USER_AGENT'])) {
			$robots = explode("\n", str_replace(array("\r\n", "\r"), "\n", trim($this->config->get('config_robots'))));

			foreach ($robots as $robot) {
				if ($robot && strpos($this->request->server['HTTP_USER_AGENT'], trim($robot)) !== false) {
					$status = false;

					break;
				}
			}
		}

		// Menu
		$this->load->model('catalog/category');

		$this->load->model('catalog/product');

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

		$categories = $this->model_catalog_category->getCategories(0);

		foreach ($categories as $category) {
			if ($category['top']) {
				// Level 2
				$children_data = array();

				$children = $this->model_catalog_category->getCategories($category['category_id']);

				foreach ($children as $child) {
					$filter_data = array(
						'filter_category_id'  => $child['category_id'],
						'filter_sub_category' => true
					);

					$children_data[] = array(
						'name'  => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
						'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
					);
				}

				// Level 1
				$data['categories'][] = array(
					'name'     => $category['name'],
					'children' => $children_data,
					'column'   => $category['column'] ? $category['column'] : 1,
					'href'     => $this->url->link('product/category', 'path=' . $category['category_id'])
				);
			}
		}

		$data['language'] = $this->load->controller('common/language');
		$data['currency'] = $this->load->controller('common/currency');
		$data['search'] = $this->load->controller('common/search');
		$data['cart'] = $this->load->controller('common/cart');

		// For page specific css
		if (isset($this->request->get['route'])) {
			if (isset($this->request->get['product_id'])) {
				$class = '-' . $this->request->get['product_id'];
			} elseif (isset($this->request->get['path'])) {
				$class = '-' . $this->request->get['path'];
			} elseif (isset($this->request->get['manufacturer_id'])) {
				$class = '-' . $this->request->get['manufacturer_id'];
			} else {
				$class = '';
			}

			$data['class'] = str_replace('/', '-', $this->request->get['route']) . $class;
		} else {
			$data['class'] = 'common-home';
		}

		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) {
			return $this->load->view($this->config->get('config_template') . '/template/common/header.tpl', $data);
		} else {
			return $this->load->view('default/template/common/header.tpl', $data);
		}
	}
}
header tpl:

Code: Select all

  </div>
</header>
<?php if ($categories) { ?>
<div class="container">
  <nav id="menu" class="navbar">
    <div class="navbar-header"><span id="category" class="visible-xs"><?php echo $text_category; ?></span>
      <button type="button" class="btn btn-navbar navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"><i class="fa fa-bars"></i></button>
    </div>
    <div class="collapse navbar-collapse navbar-ex1-collapse">
      <ul class="nav navbar-nav">
      
      
      <?php if ($informations) { ?>
      <?php foreach ($informations as $information) { ?>
        <?php if ($information['children']) { ?>
        <li class="dropdown"><a href="<?php echo $information['href']; ?>" class="dropdown-toggle" data-toggle="dropdown"><?php echo $information['title']; ?></a>
          <div class="dropdown-menu">
            <div class="dropdown-inner">
              <?php foreach (array_chunk($information['children'], ceil(count($information['children']))) as $information) { ?>
              <ul class="list-unstyled">
                <?php foreach ($children as $child) { ?>
                <li><a href="<?php echo $child['href']; ?>"><?php echo $child['title']; ?></a></li>
                <?php } ?>
              </ul>
              <?php } ?>
            </div>
            <a href="<?php echo $information['href']; ?>" class="see-all"><?php echo $text_all; ?> <?php echo $information['title']; ?></a> </div>
        </li>
        <?php } else { ?>
        <li><a href="<?php echo $information['href']; ?>"><?php echo $information['title']; ?></a></li>
        <?php } ?>
        <?php } ?>
      <?php } ?>

        <?php foreach ($categories as $category) { ?>
        <?php if ($category['children']) { ?>
        <li class="dropdown"><a href="<?php echo $category['href']; ?>" class="dropdown-toggle" data-toggle="dropdown"><?php echo $category['name']; ?></a>
          <div class="dropdown-menu">
            <div class="dropdown-inner">
              <?php foreach (array_chunk($category['children'], ceil(count($category['children']) / $category['column'])) as $children) { ?>
              <ul class="list-unstyled">
                <?php foreach ($children as $child) { ?>
                <li><a href="<?php echo $child['href']; ?>"><?php echo $child['name']; ?></a></li>
                <?php } ?>
              </ul>
              <?php } ?>
            </div>
            <a href="<?php echo $category['href']; ?>" class="see-all"><?php echo $text_all; ?> <?php echo $category['name']; ?></a> </div>
        </li>
        <?php } else { ?>
        <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li>
        <?php } ?>
        <?php } ?>

      </ul>
    </div>
  </nav>
</div>

<?php } ?>
header model:

Code: Select all

<?php
class ModelCatalogInformation extends Model {
	public function getInformation($information_id) {
		$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_description id ON (i.information_id = id.information_id) LEFT JOIN " . DB_PREFIX . "information_to_store i2s ON (i.information_id = i2s.information_id) WHERE i.information_id = '" . (int)$information_id . "' AND id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND i.status = '1'");

		return $query->row;
	}

	public function getInformations($parent_id = 0) {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_description id ON (i.information_id = id.information_id) LEFT JOIN " . DB_PREFIX . "information_to_store i2s ON (i.information_id = i2s.information_id) WHERE i.parent_id = '" . (int)$parent_id . "' AND id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND i.status = '1' ORDER BY i.sort_order, LCASE(id.title) ASC");

		return $query->rows;
	}
	
	public function getInformationLayoutId($information_id) {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information_to_layout WHERE information_id = '" . (int)$information_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'");

		if ($query->num_rows) {
			return $query->row['layout_id'];
		} else {
			return 0;
		}
	}

	public function getTotalInformationsByInformationId($parent_id = 0) {
		$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_to_store i2s ON (i.information_id = i2s.information_id) WHERE i.parent_id = '" . (int)$parent_id . "' AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND i.status = '1'");

		return $query->row['total'];
	}
}

New member

Posts

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

Post by masterbeta » Sat Mar 12, 2016 8:37 pm

hmmmm just noticed, maybe it's supposed to have the column field after all? i removed it thinking it wasn't needed....

thoughts?

New member

Posts

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

Post by masterbeta » Sat Mar 12, 2016 9:12 pm

masterbeta wrote:hmmmm just noticed, maybe it's supposed to have the column field after all? i removed it thinking it wasn't needed....

thoughts?
nope

makes no difference...

lastly i'm thinking possibly the "bottom" vs "top" fields.... i did not include "top" since i didn't plan to include in the top menu because i added to show in top menu when bottom is not selected...

i'm wondering if top is truly needed ?

New member

Posts

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

Post by artcore » Sat Mar 12, 2016 9:14 pm

Code: Select all

Works with a small change to the tpl

<?php foreach (array_chunk($information['children'], ceil(count($information['children']))) as $child_information) { ?>
												<ul class="list-unstyled">
													<?php foreach ($child_information as $child) { ?>
														<li><a href="<?php echo $child['href']; ?>"><?php echo $child['title']; ?></a></li>
													<?php } ?>
												</ul>
											<?php } ?>

You reused $information in the loop but it was already defined earlier, I just renamed it to $child_information

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 Mar 12, 2016 9:36 pm

jeanyuss!

it works - thanks a whole heck of a lot! :D this was certainly frustrating me :)

now everything is working perfectly ;)

let's see now if we can figure a way to place the "products" within the information menu headings? lol

so now i have:

infoparent1 | infoparent2 | infoparent3 | productsparent <----the categories part

i'd like to have:

infoparent1 | infoparent2 | productsparent | infoparent3

is that asking too much? hahahaha if so, it's no big deal, will just work with it as it is....

again thanks so very much!!

would you all like the finalized files once complete? it will not be as an extension since that'll take time to write out.... lol

New member

Posts

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

Post by artcore » Sat Mar 12, 2016 9:45 pm

Awesome.
I started a menu app last year but got entangled in other projects. If you want to easily extend and have full control you should create a standalone menu that can be built with whatever element in any order and of course different colors, icons, layouts and why not have each store and language have their own menu? And on top of that everything draggable/sortable in admin.

Well that was my plan ;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 » Sat Mar 12, 2016 11:02 pm

hehehe that's a great plan! :D maybe one day! for now my client wants a working menu ;) hahaha
i think i owe you a drink or two :D

after i finish this little project i'll post up the code changes i made in case anyone wants to have information become a hierarchy - again thank you all for your wonderful help especially you artcore you're my new oc fan :D hehe

for now i can create information pages with a menu/submenu and have alongside the menu bar with the products/shop - now, i'm going to tackle bg images for each information page - i want to be able to have a custom background image for each information page by simply uploading an image - i already have everything in place (in admin side i included the image support functions to upload an image, now i just simply have to create the bg css property for the info tpl)

of course naturally i'll post again once i run into a problem

consider this post 'solved' as of now :)

New member

Posts

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

Post by masterbeta » Sun Mar 13, 2016 5:58 am

so my inline css doesn't seem to be working... haha ;)

what is trumping my inline css?

New member

Posts

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

Post by cyclops12 » Sun Mar 13, 2016 6:03 am

looks like you have figured out all the main stuff so a bit of css should be easy for you ;D

would be good to see the finished product

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by masterbeta » Sun Mar 13, 2016 6:13 am

cyclops12 wrote:looks like you have figured out all the main stuff so a bit of css should be easy for you ;D

would be good to see the finished product
hehe yes a simple css *should* be working.... lol but it's not! ;)

background image uploads very well, full size as i've removed the tool/resize function on upload for information, the tpl css i've added in source shows the image, i can hard link into the image from the link it spits out - but it just simply isn't showing on the page as expected... i think it's telling me to go to sleep... lol and try again tomorrow after some fresh coffee :D

will keep you all updated ;)

New member

Posts

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

Post by masterbeta » Sun Mar 13, 2016 6:38 am

ok fixed it now it's working ;)

problem?? not awake enough ;)

tomorrow now will test all, and "package" it up for you guys to test out as well

sleep time = now!

New member

Posts

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

Users browsing this forum: No registered users and 72 guests