Magento2 custom page templates - magento2

I have developed a custom Magento2 theme and created a Generic Page layout at Vendor/Theme/Magento_Theme/layout/default.xml. In that layout i have configured my custom generic layout to use Header - Content - Footer. I have set the menu positions and the appropriate blocks.
I am now looking for some static pages to use a template and within Content Area (of the Generic page layout). For example Home page must have a banner slider and Contact page must have a Google map. Is there any way to configure it to my theme?? Is that the page_layout section of my theme??? I cannot find any customization there.

Did you look at default Core file? For example
vendor/magento/module-theme/view/frontend/layout/default.xml ?
vendor/magento/module-theme/view/frontend/templates/html/footer.phtml
<div class="footer-container">
<div class="footer">
<?php echo $block->getChildHtml() ?>
<p class="bugs"><?php /* #escapeNotVerified */ echo __('Help Us Keep Magento Healthy') ?> - <a
href="http://www.magentocommerce.com/bug-tracking"
target="_blank"><strong><?php /* #escapeNotVerified */ echo __('Report All Bugs') ?></strong></a>
</p>
<address><?php /* #escapeNotVerified */ echo $block->getCopyright() ?></address>
</div>

Related

Magento: How to Display Product Images by Image Role

I am trying to figure out how to display product images by their image role inside Magento_Catalog/templates/product/image_with_borders.phtml
Each product on my shop page will have three images each with their own image role (base, preview, hover).
This is how my product currently looks:
Here is my image_with_borders.phtml file:
<?php /** #var $block \Magento\Catalog\Block\Product\Image */ ?>
<img
src="<?= $block->escapeUrl($block->getImageUrl()) ?>"
alt="<?= /* #noEscape */ $block->stripTags($block->getLabel(), null, true) ?>"
class="main"
max-width="<?= $block->escapeHtmlAttr($block->getWidth()) ?>"
max-height="<?= $block->escapeHtmlAttr($block->getHeight()) ?>"
/>
<img src="" alt="" class="preview">
<img src="" alt="" class="hover">
How can I request the images with the roles, base, preview and hover in this file?
If you have already identified a file to modify you can use js or knockout js to alter the image according to its role.
For example image with the hover role, you can use js with hover event, when the user mouse over you can process to change the image.

Magento include phtml file within another phtml file

I am making a custom home page for my magento website in a phtml file named home_banner.phtml, which in turn i have referenced in the CMS->Pages->Home Page content by the following code
{{block type="core/template" template="theme/home_banner.phtml"}}
In my home_banner.phtml I have called tags/popular.phtml to display the popular tags.
<div class="last-posts-grid clearfix">
<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('tag/popular.phtml')->toHtml(); ?>
</div>
However the tags are not being displayed even though the anchor tag which says "view all tags" id getting called correctly. The ul class="tags-list" is also visible in the page source but the tags themselves are not visible. Any suggestions?
You made a small mistake in the template file. Your template file has to be as below:
<div class="last-posts-grid clearfix">
<?php echo $this->getLayout()->createBlock('tag/popular')->setTemplate('tag/popular.phtml')->toHtml(); ?>
</div>
I tested this and its working fine.. Hope this helps..

Show/hide Iframe

I am using wordpress for my website and I am trying to set up my pages so that a user has to click a button to view the content. Yes, very simple with show/hide etc but the button I Want the user to click is this http://www.facebook.com/plugins/like.php
To display that in my page i need to use an iframe which is where it gets tricky. I have set up the show/hide code so that when a user clicks the like button (or anywhere in the iframe) it will display the content. But, no such luck!
This is my code
<div id="imagebox" style="display:none;"><?php $image = wp_get_attachment_image_src(get_field('image'), 'full'); ?>
<img src="<?php echo $image[0]; ?>" alt="<?php get_the_title(get_field('image')) ?>" /> </div>
<div onclick="ShowDiv()"><iframe src="http://www.facebook.com/plugins/like.php? href=http://www.facebook.com/BrandBang&" allowTransparency="true">
</iframe></div>
<script language="javascript">
function ShowDiv()
{
document.getElementById("imagebox").style.display = '';
}
</script>
I know that it is hard to use iframes to do what I am trying to do, but i am a total newbie when it comes to this stuff. Any help would be great!
Have tried giving your div an id="imagebox"?
EDIT:
This was already answered here.
But, I didn't realize at first sight that you're loading something in the iframe that is not coming from your own domain, so you're going to fall in a cross site scripting event, which is not allowed.
Afaik, you have to redesign some way your implementation.
For instance, you could retrieve the generated html from facebook using curl and then outputting in your own div. Something like that should work.

Form tag is stripped off in Cake Php

Form tag is stripped off in Cake Php view file.
In 'login.ctp' (Layout view)
<div id="test">
<?php echo $this->Form->create(); ?>
Test form Elements
<?php echo $this->Form->end(); ?>
</div>
When checked in firebug console only creating below tags
<div id="test">
<div style="display:none;"><input type="hidden" value="POST" name="_method"></div>
Test form Elements
</div>
// "<div style="display:none;"><input type="hidden" value="POST" name="_method"></div>". This div tag is automatically created.
I also created a 'inner.ctp' on elements in views and tried to call from layout view(login.ctp) as echo $this->element('inner') , but results in same problem
Can any one help?
I'm almost certain that you have another form on your page, probably in your layout, that you're not closing with...
echo $this->Form->end();
If this is not the case, I suggest getting the latest stable version of Cake 1.3 and overwriting your current one.

Zend Framework: Is there a View Helper to display View Name in Layout Class?

As the title suggests, I'm trying to find a way of displaying the title of the View currently being displayed as part of the layout. I'm trying to do this so that the page title is dynamicly populated when a different view is selected.
In psuedocode:
<div>
<div id="header"><h1>My website</h1></div>
<div id="main">
<?php echo "<h2>" . SOME WAY OF ECHOING THE VIEW NAME HERE . "</h2>"; ?>
<?php echo $this->layout()->content; ?>
</div>
<div id="footer"><p>2011 My website.com></p>
</div>
I've been through the Zend documentation and the closest thing I could find was the headlink. However, I was unable to get the value from this helper and shoehorn it into a variable so that I could display its text as a page header for the view.
Thanks.
You could pass the action name (or combine with the module if needed) to the layout within the controller.
$layout = $this->_helper->layout->getLayoutInstance();
$layout->viewName = $this->_getParam("action");
Kind of dirty, but it would work
I´m not quite sure if I understood you right, but there´s something called a placeholder in ZendFramework. Basically you define the placeholder and fill it afterwards with whatever you want.