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

Code snippets and logic
 
conticreative
Member
 
Total Posts:  38
Joined:  2007-12-13
 

Greeting to all in Magentoland. I am very new to Magento but I am an old salt integrating all sort of Open Source projects, from Zen Cart to Drupal, to Joomla (which is my CMS of choice).

In studying Magento I realized that much of the front end presentation is done via custom tags in {{this type of format}}, which reminds me of the old days integrating a custom java application in the 90’s.

I was able to retrieve a few snippets of syntax here and there in the forum, with some working fine and others not so well, but I was wondering if there is a snippet repository somewhere I can refer to. I can’t seem to find anything like it and what I find is often old enough to be possibly obsolete.
I did read a few posts of kind souls that tried piecing together the most used snippets in their forum posts, giving me a hint that such repository was not in existence at the time of their writing.
Such a repository would be very useful I believe.

I’d appreciate if someone could point me in the right direction as to where I can find a full explanation of the Magento syntax, complete with code snippets that actually work. And yes, I did read the manual. Did Imiss it?

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
NOTE: Below is something I wrote about my first impressions with Magento. Read only if interested, it’s not related to my request for help.

On a related but separate topic, I have to say I am not very happy with Magento’s choice to “shield” designers from the bad, ugly code. In my experience whenever a project tries to do that it only succeeds in creating yet another syntax I have to learn and make yet another layer of logic on top of the core functionality.

In my opinion, a loop is a loop and a conditional is a conditional. We can choose to write it in curly brackets or in php but it is essentially the same thing. I understand that some designers are still reticent of learning simple coding and get scared when they see multicolored (in their IDE) php code. Although their number is thankfully dwindling, It’s probably for that reason that some projects develop their own syntax, or use existing templating syntax most designers have learned to hate, and try to fool the designers in believing it is not code. It is.

I for one would much rather deal with PHP than yet another curly bracket syntax I have to learn from scratch. However, if I do have to learn it, I would very much prefer not having to hunt down every snippet in the user forum.

I have to say that Magento’s administration and front end code are very impressive. A benefit derived from the fact they had the luxury of designing it from scratch using the latest coding standards.

Ever since Magento came out a year or so ago, I have tried very much to love it. But the fact that the presentation files are scattered all over the place has prevented me from really enjoying working with it and ultimately learn it properly.

Now I have no choice and I am looking forward to familiarize myself with the system, but I still don;t like having to open a dozen directories to reach template files and having to deal with obscure syntax. It reminds me in a way of working with OScommerce, where a template change meant altering 15 different files across the platform. Granted, Magento’s are better organized and the code is a marvel of cleanliness compared to OSC, but I would be enjoying the process a lot more if it used a template directory like many of the other projects do. And an installer would also be a welcome addition, now that I think of it.

I have not gone as far as installing any modules (or whatever they are called) BUT I am sort of dreading the idea.

Say what you want about Joomla, a project chained codewise to the year 2000 by the Mambo heritage, but its “installer” system, by which a mentally challenged chimp can install pretty much 99% of available plugins, modules and templates, is a marvel of efficiency and straightforwardness.

Even after installing the add-ons, templates included, it is extremely intuitive where those files ended up and where to go make any changes.
I am sure in time Magento’s system will seem just as easy to me, but it sure isn’t when first approached and that’s for someone like me that is very conversant in about 4 CMS and 3 e-stores, know another dozen well enough to build a simple site with them in an afternoon and have been doing this for the past 15 years or so (6years in Open Source).

It’s not that I am bragging, but with the kind of experience I have accumulated it’s usually pretty easy for me to work with a new CMS or shopping cart for an hour or so and figure out at least where the major parts are located and how to do the basic changes needed to make a site live.
Not so with Magento. I ended up dusting off my laptop so I could place it next to my main monitor and read the manual while working on the site I am building. I’d hate to see what the learning curve is like for someone used to build static website.

Before the Magento fan club sharpens their pencils and come after me for heresy, I want to point out that I am really impressed by the software and the obvious effort the programmers have done to create a world class application. The code, especially compared to monstrosities like OSCommerce, is a think of beauty. I just wished that they used a more compact template system than what I have seen so far.

I hope someone out there will try to prove my point wrong and show me how misguided I really am. I hope so because I have to launch a site in a week and at this pace I am going to miss the deadline.

Thank you for reading so far and I am interested in any opinion on the topic. I may learn something to speed up the learning process.

I wish you all a good day.

 
Magento Community Magento Community
Magento Community
Magento Community
 
SeL_
Magento Team
 
Avatar
Total Posts:  1140
Joined:  2007-10-10
Paris, France
 

Hi conticreative,

First of all, welcome to the community.
Second, thanks for the kind words about Magento.

When you request an installer for Magento, i don’t understand. Actually, there is already one and Magento Connect for extensions.
Core, community and local parts of code are separated so you would not have problem with distinguish one from the other.

About snippets, Magento lets you the choice either to code with snippets (which is limitated) or to write PHP code (MVC and phtml templates). This is very powerful but needs practice before loving it. More than an hour, for sure wink

Don’t be afraid, you won’t be burnt for heresy !

Thanks again for sharing your impressions.
Happy e-Commerce with Magento !

 
Magento Community Magento Community
Magento Community
Magento Community
 
conticreative
Member
 
Total Posts:  38
Joined:  2007-12-13
 

Hi, thank you for your kind answer. You are right, I was aware of the installer you are talking about. However, when I first tried to install Magento via the automated installer (whatever is called - as opposed to downloading the complete core files… am I making any sense) I was unable to make it work and I tried on my dedicated server, a shared account and on my own Apache XAMPP server. In all three cases I was not able to either expand the archive or to connect once I was able to expand it.

That also prevented me from exploring any other automated features Magento has. Plus, I wanted to know what was going on and where all these files went.

I guess what I meant was an installer in the vein of the Joomla installer: a single page where to upload an archive to that then distributes the various add-on’s files across the file system.
My client purchased a few modules for his Magento installation and in the installation instructions there was no mention of an automated way of installing them. In fact, by looking at the files I don’t see how that would be possible.

As I mentioned, I am very new to magento and I love the way it works in the front end and the way the administration is organized, but from the point of view of a developer/integrator, it seems as it’s not quite where it should be yet.
Installing templates should be far easier than it is as that would allow designers to offer far more unique templates to the community. At this time, and from what I understand, installing a template is far too involved for someone that doesn’t have skills and experience in at least HTML or PHP.

I think Magento has a lot of potential and the community you guys have built around it is really impressive. But when I try to compare the execution of fairly mundane tasks in Joomla, Drupal and others with the way Magento works, the latter seems far less friendly and not quite where it should be.

In another post one of the developer espressed his opinion that at some point someone will write a good template system for magento. That tells me you guys are aware that it’s less than ideal as it stands now. But you should not be waiting for someone else to do it.
Drupal made that mistake and in version 5 there were at least 3 major templating systems available. Instead of making things better, it created a situation where there were far less templates available and the one your client wanted was usually done in the system you had not learned yet.

I understand that magento is trying nopt to repeat the pitfalls of previous e-commerce scripts, but ignoring the history of OScommerce, Zen Cart and co. is also not a good idea.

OScommerce never had a template system worthy of the name. To make even a simple template it required working on, and keeping track of, several files in the system instead of a single min file. Magento reminds me a lot of OSC in that respect.
I tried working with a commercial template and I found myself going back and forth between my IDE and the administration, back and forth and over and over.

Naturally, in part that;’s because of my inexperience, but at the same time I am able to write templates in about a dozen different systems and Magento’s is the first one that is giving me serious pause.

Again, that takes nothing away from the splendid job you guys did on the actual store. It is by far the best ever. From my standpoint though, I wish I could fast forward a few years in the future when some things will have gelled a bit more.

To get back to my original question: where are the snippets of code? Is there a repository or do I have to hunt them down in the forums?

Thank you again for your kind response.

 
Magento Community Magento Community
Magento Community
Magento Community
 
SeL_
Magento Team
 
Avatar
Total Posts:  1140
Joined:  2007-10-10
Paris, France
 

AFAIK, there is not yet a snippets list. More documentation is coming, but no timeframe for this.
Plus, we encourage the community to use the wiki and other tools on magentocommerce.com platform to share knowledge and writing documentation.
Hope this will be available soon.

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