I know this is a simple question but I have been searching for days and cannot come up with a reasonable answer.
How do you define "class-side" methods in Pharo 6? Something like "static" in other languages
Thank you so much for your help!
EDIT:
Solved! Thank you!
There is a Class button right below the list of classes in the Browser. Click on it and it will take you to the class side. Meaning that the selectors on the right pane will now belong in the class. To create a new method, just overwrite anyone or the template. Then CMD+s to accept (save) it. To come back to the instance side, click the Class button again (it's a toggle.)
Related
So I'm new to OO Programming. Coming from a WebDesign Background and having done mostly design work or some more or less intermediate scripting wherever it was needed in my projects. But being eager to learn and still searching for the "right" way ;-) to do things like you guys do. Not what my Script Kiddie Mind tells me :D. So sorry if that is really a super beginner question, but I would rather grasp the "right" concept from the start.
I'm programmatically populating a NSMenu with NSMenuItems based on contents of a folder located in my Documents Directory. I'm iterating through the subfolders of this fellow, getting the URL of each and every one, extracting the folder name by using
let folder = el.URLByDeletingPathExtension?.lastPathComponent
and creating NSMenuItems based on those names
let menuItem = statusMenu.insertItemWithTitle(folder!, action: #selector(StatusMenuController.doFancyStuff), keyEquivalent: "", atIndex:0)"
So far so good. Now how would I store the associated URL along with the MenuItem for later use like manipulating it when the action gets triggered?
By clicking on the item I want an action to be performed, which needs the full folder URL of course. My first idea was to extend NSMenuItem with a new variable called "path" or so. But since there are no stored values allowed in extensions this is a dead end.
How do you real programmers handle such cases? Using a dictionary and storing the Items along with their respective URLs? Could work, or not? But would that be the correct way? Or getting the full url by taking the MenuItems Title and "reattaching" it to the basefolder URL? Which could also work. Or do you hand the URL to the method/action that will get called as an attribute? I would really love to stay away from messy code :) so your pro insights are very much appreciated.
Thank you for your Time!
andy
NSMenuItem has a property representedObject which can be used for that purpose.
From the documentation:
By setting a represented object for a menu item, you make an
association between the menu item and that object. The represented
object functions as a more specific form of tag that allows you to
associate any object, not just an arbitrary integer, with the items in
a menu.
If you want to store more information than just an URL you could also assign a collection object like Array or Dictionary or even a custom class to representedObject.
Basically I have to generate PDF of wishlist items(products) using the chunk of codes as specified in http://gorrc.blogspot.in/2012/05/magento-print-whishlist-to-pdf.html.
Now the problem is, I am not able to trace out where and how to call all the methods as specified in above link. Can anyone help me in this or provide any alternate solution, I mean some other ways for generating PDF of wishlist items. Any Help will be highly appreciated!
How you want to do it?
Say more about where you want do this action and i'll point the right direction.
This is controller, its end point of url request.
Method is called when you navigate to specified URL.
Having no luck here trying to find a solution to this.
I've set up a looping selector based on this guide. (I also used the ListLoopingDataSource class in Part 2 in order to have strings in my looping list).
What I want to be able to do is then change another element (an image box/placeholder) on my layout, based on what is currently selected in the looping selector.
No real idea how to do this, the onSelectionChanged event is kind of abstracted and not really useful? I'm not sure how to programmatically change images either, it doesn't look like I can access a resource from the code base, only from the xaml.
Any help/suggestions would be greatly appreciated.
I found that I could do this by using binding.
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.
Hi I just want to know that how can i add Subccategories in the Navigation menus without making the parent category to show up there Any Ideas???
thanks in advance
This will take quite a bit of surgery to make this happen in a programatic fashion. You'll need to override the Mage_Catalog_Block_Navigation::_renderCategoryMenuItemHtml() method.
Alternatively, you might be able to hide the parent categories using your skin's CSS? The ul#nav li elements have quite specific class and id values that should allow you to show or hide them. However I suspect given the complexity of the fly-out nav, you may find it more efficient to rewrite the PHP. It probably comes down to where your proficiency lies.
HTH,
JD