AbanteCart Community

AbanteCart Development => Customization help => Topic started by: ymaster on January 10, 2016, 06:32:30 AM

Title: pop up Newsletter
Post by: ymaster on January 10, 2016, 06:32:30 AM
Dear Sir,
             how can i make Newsletter popup for my site front page
Please reply soon as possible
Title: Re: pop up Newsletter
Post by: eCommerce Core on January 10, 2016, 02:08:15 PM
As soon as possible?  :o

See if this will help you:
http://stackoverflow.com/questions/19707236/show-popup-after-page-load

You can add this code as new block or add it into header/footer template (.tpl)
Title: Re: pop up Newsletter
Post by: Trendslink on May 02, 2016, 04:17:17 AM
i need this also. Anybody can teach how to do that? i'm nooby
Title: Re: pop up Newsletter
Post by: abantecart on May 05, 2016, 07:53:15 PM
There is a quick and right approach to implement new code.

Quick and dirty approach is to integrate your HTML and JavaScript that opens popup into header of the storefront.
Code can be added into following template file:
storefront/view/default/template/common/header.tpl

For right approach will require creation of the block to be used in the layout. This can be done in the core or as an extension:

Overview:
1. Create new block in SQL that can be enabled in the layout
2. Create controller/template files for the block
3. Add Javascripts and css if needed.
4. Build extension if needed.
Note: the block now can be included in to any place in the layout. Since this block will occupy no space and will only show popup, it can be included in any location on the layout.

1. To insert block into the system you can perform 2 ways.
a. Create block with series of SQL insert statements (I will not bother here, Feel free to check tables).
b. Create block with running XML for layout.
Check this manual for layout/block section
http://docs.abantecart.com/pages/developer/template_customization_or_development_guide.html

Basically you need to run below code 1 time or include in extension installation file
                        
$file = DIR_EXT . 'layout.xml';
$layout = new ALayoutManager('default');
$layout->loadXml(array('file' => $file));
                        
Where layout.xml is file with new block:

                <block>
                    <block_txt_id>newsletter_popup</block_txt_id>
                    <controller>blocks/newsletter_popup </controller>
                    <templates>
                        <template>
                            <parent_block>header</parent_block>
                            <template_name>blocks/newsletter_popup.tpl</template_name>
                        </template>
                    </templates>
                </block>
                        
2. Create 2 new files
Controller:

storefront/controller/blocks/newsletter_popup.php

Tempalte:

storefront/view/default/template/blocks/newsletter_popup.tpl

Now you can code your controller and template.

3. JavaScripts and CSS are going to
/storefront/view/default/javascript
and
/storefront/view/default/stylesheet

You can include them with methods addScript(), addScriptBottom and addStyle() in the controller or you can include them in the head.tpl

4. You can build extension with Devtools
http://docs.abantecart.com/pages/developer/template_dev_tools.html


Note: Allot of information about architecture, layouts and blocks can be located in the manuals:
http://docs.abantecart.com/pages/developer/architecture.html