Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Creating blank page where we can use methods from magento
 
Jean Denis
Jr. Member
 
Total Posts:  7
Joined:  2008-09-02
Brussel, Belgium
 

Hi all,

I need to add a link to give the possibility to the customer to see the biography of an artist into a pop-up

What’s the best solution to create this page and to get the possibility to call the Load or the getData methods ?

Tks for your help

 
Magento Community Magento Community
Magento Community
Magento Community
 
LeeSaferite
Guru
 
Avatar
Total Posts:  322
Joined:  2007-08-31
Lake City, FL
 

See this:
/magento/app/design/frontend/default/default/layout/catalog.xml:289

This is how Magento creates a ‘popup’ style layout

So, you should have your custom module and make an entry in the layout XML for your module that does that.  Then you create the link to your custom module.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jean Denis
Jr. Member
 
Total Posts:  7
Joined:  2008-09-02
Brussel, Belgium
 

Ok, i checked this file.

But where do i link my popWin to this kind of page.

I duplicated the <catalog_product_gallery> in the catalog.xml with my information.

I create two files based on Gallery.php and gallery.phtml but what i don’t understand is how on this link the system gives the kind of pages it needs

<a href="#" onClick="popWin(’<?php echo $this->getGalleryUrl($_image) ?>’, ‘gallery’, ‘width=300,height=300,left=50,top=50,location=no,status=yes,scrollbars=yes,resizable=yes’); return false;"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(68, 68); ?>” width="68" height="68" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>” title="<?php echo $this->htmlEscape($_image->getLabel()) ?>” /></a>

it just gives the url of a jpg, how the opened pop-up contains html from gallery.phtml ?

i don’t understand where in media.phtml i mention i will call gallery.phtml ???

 
Magento Community Magento Community
Magento Community
Magento Community
 
LeeSaferite
Guru
 
Avatar
Total Posts:  322
Joined:  2007-08-31
Lake City, FL
 

Ok, you’ve got lots going on I don’t understand.  But I’ll simplify a little

You want a simple popup page that doesn’t have all the rest of the layout (header/footer/etc).

The code you posted is using

$this->getGalleryUrl($_image)
(/magento/app/code/core/Mage/Catalog/Block/Product/View/Media.php:47)

That method returns a url pointing to /catalog/product_gallery/id/???/image/???
This new URL is serviced by /magento/app/code/core/Mage/Catalog/controllers/ProductController.php:143
This action gets it’s layout info from the <catalog_product_gallery> element
That element is telling the ‘root’ block to use ‘page/one-column.phtml’ as it’s template file.
This template file is stripped down HTML file that doesn’t display headers or any of that stuff.

So, on to what you want to do

You should be writing your code as a module, it makes it easier to install and maintin, plus it means you can use an license you want on it.

So, say your module is YourCompany_YourModule
You need to have a controller to handle requests, say YourCompany_YourModule_ArtistController
You should have an action to render the biography as a popup, say biographyAction
If you set the frontname for your module as yourmodule then in your custom layout file (/magento/app/design/frontend/default/default/layout/yourmodule.xml)
You should have an entry like this

<yourmodule_artist_biography>
        <
reference name="root">
            <
action method="setTemplate"><template>page/one-column.phtml</template></action>
        </
reference>
        <
reference name="content">
            <
block type="yourmodule/artist_biography" name="yourmodule_artist_biography" template="yourmodule/artist/biography.phtml"/>
        </
reference>
    </
yourmodule_artist_biography>

Then you can get a url to this like so:

$this->getUrl('yourmodule/artist/biography', array('artist'=>'Sia')
or maybe
$this->getUrl('yourmodule/artist/biography', array('artist'=>100234)

That will result in this url
/yourmodule/artist/biography/artist/Sia
or
/yourmodule/artist/biography/artist/100234

You just need to use the code you already listed to show a popup via javascript and the code I showed you to get a URL.

Now, the above example is leaving out all the basic setup you need to do for a module, which you can find it other places.  If you need help with that, let me know.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jean Denis
Jr. Member
 
Total Posts:  7
Joined:  2008-09-02
Brussel, Belgium
 

Tks for your help,

I’ve still one big problem…

I don’t really understand how does the controller work ?

Do you have any link to documentation about this ? or any help ?

Here is what i did:

i tried to duplicate gallery with gallery2 in the catalog.xml

<catalog_product_gallery2>
<!-- Mage_Catalog -->
<reference name="root">
<action method="setTemplate"><template>page/one-column.phtml</template></action>
</reference>
<reference name="content">
<block type="catalog/product_gallery2" name="catalog_product_gallery2" template="catalog/product/gallery2.phtml"/>
</reference>
</catalog_product_gallery2>

i duplicate the files gallery.phtml -> gallery2.phtml and Gallery.php -> Gallery2.php

the only change is in gallery2.phtml i add “test” before the <img />

i create manually the url replacing gallery by gallery 2 (the url’s are the same in the final code except for gallery2)

<a href="#" onClick="popWin(’http://localhost:8888/artemptation-2/index.php/catalog/product/gallery2/id/108/image/175/’, ‘biography’, ‘width=300,height=300,left=50,top=50,location=yes,status=yes,scrollbars=yes,resizable=yes’); return false;">test</a>

what’s wrong ?

tks in advance

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top