AbanteCart Development > Customization help

Custom layout; different layouts for GS1 & GS2

<< < (3/3)

abantecart:
I think your problem is with the code in the install.

You have template ID of joe:

--- Code: ---<template_id>joe</template_id>
--- End code ---

But in the code you use default:

--- Code: ---$layout = new ALayoutManager('default');
--- End code ---

Try this:

--- Code: ---<?php

if (! defined ( 'DIR_CORE' )) {
header ( 'Location: static_pages/' );
}

$file = DIR_EXT . '/joe/layout.xml';
$layout = new ALayoutManager('joe');
$layout->loadXml(array('file' => $file));

--- End code ---

Geoffrey:
Hi, thanks again for your help. 

I made the change you suggested to install.php, and then cleared all cache, but it did not work. 

My new Layout "GS1 Layout" appears in the Layouts dropdown menu for both the default and joe templates, but it is empty regardless of template selected.  (It has a "Content Area", but no other blocks or sections.)

Food for thought:  I am using a template extension.  It was a clone of default.  I used Admin to modify all of the available layouts for my extension. 
Before today, I have never edited the install.php file in my extension folder root.
Until today, the ALayoutManager value was always 'default'. 
My site works.  My layout modifications work.  My template extension works. 
Everything works despite the difference between template_id value 'joe' in layout.xml and the ALayoutManager value 'default' in install.php. 

Changing the ALayoutmanager value from 'default' to 'joe' did not affect any part of my site, and it did not populate the new GS1 Layout with the fields or blocks specified in the layout.xml file. 

So I'm still trying to solve the 1st problem.  I can edit the tables to create a new layout, and I can specify the components of the new layout in layout.xml, but when I open the new layout in Admin, it is empty. 

Thanks for helping me solve this. 

Geoffrey:
Hey, I got it!

To add a new custom layout for a checkout page, use phpMyAdmin to edit four tables in your database:

1 - add the new layout to the _layouts table.

2 - add a new page to the _pages table.  This won't be an actual new page, but rather a more granular specification of an existing page.  In default AC, all checkout pages except the Cart page share the same layout.  In the _pages table, you will see 2 rows for checkouts pages:
a - pages/checkout
b - pages/checkout/cart
The system applies the Checkout Pages layout to all checkout pages except the Cart page, because the cart page is defined more precisely to use the pages/checkout/cart layout. 
Your goal in step 2 is to add a a 3rd row, a more specifically-defined page.  So you pick a new page_id number and use a more specific controller name.  In my case, it was pages/checkout/guest-step-1.

3 - edit the _pages_layouts table to add a new association between the new page with the new layout. 

4 - edit the _block_layouts table.  What this table does is associate various blocks with a layout.  Sort the table by layout_id.  You will then multiple rows for each layout, each row associating a block with that layout.  You made a new layout, but it will be empty until you associate various blocks.  The easiest way to do this is to pick another known layout in that table, click every box in every row of the layout, then scroll to page bottom and click Copy.  This will open a new view where you are editing every block assignment for the known layout.  Change every layout_id value from the value for the known layout to the value for your new layout, then click Go button to save.  Basically, this will clone the known layout into your new layout. 

Close phpMyAdmin.

Open your template layout.xml file in an editor.  Find the section of code for the Checkout Pages layout.  Copy everything from the <layout> tag thru the </layout> tag.  Paste that content at the bottom of the file.  Then edit the 2 <name> values you will see at the top of the pasted section.  Change them from "Checkout Pages" to whatever name you used for layout_name in the _layouts table.  Also edit the <controller> line to match the controller value you specified in the _pages table.  Save and close. 

Clear cache.

That's it.  You will now see your new Layout in Admin, and you can set it however you like. 

Thanks to Maxter and AC for bringing me far enough along so that I could recognize the missing piece: the _block_layouts table.

abantecart:
Glad you resolved it.

Navigation

[0] Message Index

[*] Previous page

Go to full version
Powered by SMFPacks Social Login Mod