Magento Module action on ProductView - magento

I have create a module which at this point does nothing but exist the next step I need to figure out is how to make it does something when someone views the a product at this point I don't care if it says hello world next to the image
can someone help me I can't seem to figure out what I need to extend if i need to use and observer or what I seem to be lost .... or drowning

Depending on what you want to accomplish, you could go in many different directions from here. If you're looking for visual feedback, creating a new block and adding it to the product page might be a good direction. Try creating a new block in your module (Yournamespace_Yourmodule_Block_Product_View in the file app/code/local/Yournamespace/Yourmodule/Block/Product/View.php) and define a method toHtml in that block that echos some HTML (say "hello world"). Look at other blocks in the system to see how to set up such a class (what to descend from, etc). Later on, you'll want to turn this into a proper template, but this approach will help you understand blocks. Check Alan's other tutorials for how to set up your config.xml to define where blocks are found.
Now, inside your theme, in /templates/catalog/product/view.php, create an instance of your block and display it's contents like this:
<?php print $this->getLayout()->createBlock("yourmodule/product_view")->toHtml(); ?>
This should echo some HTML onto the product view page.
I want to emphasize that this skips several of the steps to doing it the "right" way, but it should get you quick visual feedback and help you understand how a page is built inside of magento.

Related

Comic navigation in joomla?

I have a joomla site and would like to integrate some old unfinished webcomics to it, so I can pick them up where I stopped in a CMS that won't leave me in an absolute frothing rage (thanks, wordpress).
I've got some experience with Joomla and I believe it would be a pretty good platform for managing multiple comics... except for the small issue of horrid navigation between pages/articles. Joomla's integrated article navigation is a humble but passable start, but if you intend to use categories to organize chapters then getting from the end of one to the beginning of the next is... yeah. This is a pity, as Joomla's category and article management options are beautiful for archiving and presentation, and adding gantry 5 to it means a great deal of control over the reading experience. Basically, joomla has pretty much everything I want, except for the navigation.
Ideally, what I'd like to be able to accomplish for comic navigation in joomla is:
Clickable full-article-image leading to next article/page
Prev/next article buttons (already available)
Prev/next category buttons (do we have those?)
The latter two in a module I can choose where to publish (optional)
And this is it, basically. I understand that implementing the first could be very hard without some major template customization, in which case I'd be willing to insert the image as a link in the article body... but only if there was one single code I could use, like the one that generates the next category article button. Because I'm not willing to create hundreds of menu items to generate links page-by-page.
So is any of this doable?
This is a quick answer but too much for a comment. I'm assuming since you are on SO that you don't mind coding (as opposed to just configuring).
I think you need to do two things. First you need to create a pagination.php for your template. This will let you really super control what the pagination looks like. You can have images, special css and js, whatever you want. You can also add the "last" and "first" options.
I think you need to make a new plugin to replace the core pagenavigation plugin and that also generates the previous/next category links. (Or I guess you could make one just to do categorynavigation depending on what you want.) HOWEVER, it seems to me that there is data on the sibling links that is already being generated in the content category model so you might be able to use that. (Check the code; I think there was never a UI for it, but it is there. Even if it isn't there, siblings are very easy to obtain in nested sets)
The other thing you can really think about if you go that route is changing the whole thing somewhat to use a module that gets the current ID and category ID from JInput. You might also be able to use JPagination. The important thing, however is that you make sure to do the caching the way the pagination that is there does it. In other words you really want to cache the whole list in the order you want so you are not running so many queries and slowing your site down. You may want to look at the categories and category modules to get some ideas about the queries to do.
Hope that gets you started, but it is definitely something you can do without too much trouble.

Locating Layout/Template - Magento

I need a little bit of guidance. im new to Magento and getting lost with the Templates/Layout structure when it comes to design of a custom theme.
From my understanding there are two types of blocks:
Structure Blocks and Content blocks.
Structure blocks define the structure of the site and Content blocks call .phtml template files to populate the structure blocks with content (please correct me if im wrong).
I have an area that i would like to update, when i turn on the debugging in magento i am advised that the area that i wish to update is located at:
frontend\meigeetheme\default\template\meigee/meigeewidgets/grid_2.phtml
Essentially what i would like to do is get a Categories menu in this area. I expected to find the structural block in a folder within the layout directory called meigee, but i am unable to find any .xml document that represents the defining structure that this template is called in to.
Any idea how i go about it?
All advice and criticisms welcome. Thanks in advance.
Oki doki, so doing my research i found a very useful peace of code. I would like to give credit to user: djdy.
If you include within a .phtml file:
$this->getLayout()->getBlock('root')->getTemplate();
obviously:
<?php echo $this->getLayout()->getBlock('root')->getTemplate(); ?>
it will do a nice little echo of the layout being used.
Proved quite helpful in resolving my task. It seemed that grid_2.phtml was being loaded within:
frontend\meigeetheme\default\template\page\1column.phtml
then according i was able to add the block i needed in page.xml and call using getChildHtml. Hope this helps!

magento - include core functionality in custom module

I've recently made my first couple of simple modules for magento. Basically just trying out making a module that printed 'hi'. Then one that included the site design, and finally one that inserted it's own block into the content area to print some stuff.
Now, what I really want with this module is to be able to list products (using the same layout as normal product listing) but based on ID's. Like from cookies or as an example, static array of product ID's.
How would I go about to reuse the product listing code as much as possible and retaining the theming for it? Also if there is some small detail I wanted to change in the layout - how could i make a small template adjustment on the fly/programmatically?
Is this even the right way to go about it, to create a new module and somehow include existing functionality in it? Or should I just try to recreate the product listing and mimic the design?
Lots of questions I know, but it's hard to find relevant information beyond the very simplest modules. TIA.

injecting magento block to head via observed event

what magento frontend events can should I observe if I want the chance to inject blocks to the ("head" block) ?
and while in the observer's code, how do I check if the current layout has some handle (e.g. not_logged_in) set.
Give the
controller_action_layout_generate_blocks_after
event a try. The Layout object and its child blocks should be instantiated by the point that event fires.
There's only ever one Layout object, and you can grab the handles in play with
// get the layout->get the updates manager->get the handles
$handles = Mage::getSingleton('core/layout')->getUpdate()->getHandles();
var_dump($handles);
If you're working on front-end code and trying to stick to magento conventions, it's probably better to add a layout.xml file to your module, and use the layout file to add your blocks. It's less fun than figuring out something new though!
I appreciate the plug on the blog, but clockworkgeek is correct. The best way to accomplish this is to use a layout file to add the blocks you need. It is also possible for those blocks to change their own rendering behavior based on arbitrary code.
If there is a reason why you cannot use layouts, please elaborate a bit in your question and we'll be happy to help.

BEA Publisher Woes

I'm using BEA's Publisher product with ALUI. I want to have a simple portlet that just displays Content Items that I've published, but after playing with it for a couple of hours, I find myself stuck.
I have a Data Entry template that just takes a name and a file, and a presentation template associated with that. But I can't figure out how to make the presentation template display a list of published content items associated with the Data Entry template.
I tried using the Tag Helper and I saw that the file properties were available, e.g. name, location, length, however I can't get the template to actually display the information.
Also, since I can't publish said presentation template (you aren't allowed to publish a presentation template associated with a data entry template), I have to make ANOTHER presentation template, and include the first one, and then make a new portlet that displays that second template. Is this how it's supposed to work? It seems awfully complicated for such a simple task.
I would greatly appreciate any input anyone can give. Thanks!
In case anyone else runs into this:
http://forums.oracle.com/forums/thread.jspa?messageID=3171395&#3171395

Resources