Wordpress creating custom theme-Reusability - css

first approach to CMS and wordpress I'm wondering if there's any predefined html structure and classes/IDs "must-be" reference that I can refer for making my own theme willing to change in the future for another wordpress theme
thanks
Luca

There are a few other 'template' themes that could get you started - if Starkers isn't quite your thing, you might find WP Framework a good alternative. Or - just start stripping down the Twenty Eleven theme to give you a base (which is just what the Starkers theme does, using the Twenty Ten theme as a base).
There's also quite a handy first-time guide on the WordPress Codex around theme development if you'd prefer to start from scratch.

Wordpress doesn't require you to have any specific classes or IDs in your theme in terms of the HTML and CSS, the only things WP needs are things like the wp_head function inside your element on every page. Having said that themes such as Starkers were created to enable developers to have a starting point instead of starting from scratch.
Now the above applies only to whatever code you write, there are however some functions in WP that will return standard code, for instance if you don't specifically create the comment thread code, WP will generate it for you, and that is really the only code that many themes will share.
I would say that if you are intending on making a number of blogging themes for instance, having a set of standard code might be a good idea, for the article pages for example, so that you don't have to re-write code over and over. Aside from that the only code I ever reuse when making themes is the CSS to style comments if I don't hand-code the comments section, this is a good idea as it will save you a lot of time.

Wordpress provide some functions which add CSS classes depending of page type, templete, conditional tags . . .etc.
These functions are body_class() and post_class().
For more info check:
http://codex.wordpress.org/Function_Reference/post_class
http://codex.wordpress.org/Function_Reference/body_class

Related

Convert Magento theme to wordpress theme?

I had a Magento theme downloaded and i want to use it to my wordpress site. I searched wordpress version of the theme but no luck. Is there a way i can convert magento theme to wordpress theme?
There is no automatic way to do that, you will need to migrate your theme manually, with that I mean, you will need to code the theme in WordPress.
There's no way of magically rewriting a Magento theme into a Wordpress theme.
Like Enrique said, you will need to recode the entire thing.. well, almost, at least. This really depends on whether or not you simply want them to look the same or to actually be structured identically. The former is easier.
You can most likely salvage the majority of the skin folder, especially css and js. Then it's a matter of matching up Magento element names to corresponding Wordpress element names. An example might be .button and .btn.
As far as the structure, you may want to simply view source on the theme as it renders on the actual site, grab the source and do some heavy analysis. Figure out which portions render in the header, content and footer and try to piece them into the corresponding Wordpress files. It's a daunting task but believe it or not, I've done similar things before.
Note that Wordpress is nowhere near as complex in terms of application structure as Magento, so you'd really be dumbing down the Magento theme to accomplish this.
To convert your theme unfortunately you will have to manually rebuild it line by line for Wordpress. You said that you could not find the wordpress version of the theme but if possible the theme vendors might have HTML or PSD versions of the theme which would be a much closer starting point than Magento to Wordpress conversion.

Is it possible to use a regular wordpress theme without wordpress functionality

First of all i don't have any experience on wordpress.. So please forgive my ignorance.. I've found a theme on themeforest. Unfortunately it's a wordpress theme. I want to develop my own admin panel. I don't want to use wordress. Is it possible?
Anything is possible, however this is a gum in hair scenario. Ask the theme author if there is an HTML version which is common on ThemeForest. If you do try to "extract" the layout:
Begin with the stylesheet and match up the styles with each page template's markup.
Also, why not use WordPress? The Redux theme options framework is very easy to use.
Since a wordpress theme is just a bunch of html/css/js/php files, yes, it is possible. Depending on what language/framework will used backend side, the easiest way would be to extract the html/css/js parts of the theme and than add your own "content-placeholders" which will be used by your own backend.
But: Think twice about doing this. First, there could be a conflict with the license of the theme (depending on what type of license is used by the author of the theme). And more important, second, you should think twice about building your own backend.
For the case this isn't an experiment and you're building a productive website, building you're own backend is a lot of work. Unless you need some special functionalities (or you would like to keep it very slim and basic), I would suggest using a ready made CMS for this - like wordpress.
My opinion: 95% of self-made backends for basic cms features I've seen (and was forced to work with) are very messy and far beyond available open source cms. It seems like many people don't balance the pros and cons of building an own CMS-backend and undervalue the effort to build a state-of-the-art CMS.

Drupal 6: duplicate theme function in two themes

I have a regular and mobile theme for a site; there are currently a couple of duplicate functions in the template.php of each theme, which do some text munging on the same fields. That is, the markup is the same for these fields in both themes.
How can I impose DRY and only have the logic in one place?
I understand I could make the regular theme inherit the mobile theme, but this doesn't seem like a "proper" solution, since the themes are quite different at the end of the day. Even more so as this would require ex-post-facto manipulation of the preprocess functions, and overriding mobile CSS and JS files - seemingly creating as much work and future WTH as it solves.
Thanks!
I would love to see the proper answer for this.
All i can think of is making a module that holds the duplication of functionality. A library module if you will.
So I'm making this "answer" as a conversation starter.
in: (mobile)template.php
preprocess_page(&$vars){
mymodulename_pagepreprocess($vars,'mobile');
}
(desktop)template.php
preprocess_page(&$vars){
mymodulename_pagepreprocess($vars,'desktop');
}
You can have preprocess-functions in modules as well btw. But it might be nice to send witch template as an argument.(you could however extract this from the global $theme)
How about you make a base theme which holds the functions, and implement both as sub-themes of it.
Or just the mobile theme a sub-theme, and the PC theme is the base?
Creating a sub-theme

Multi-Site Drupal, theme structuring and Zen theme

Thing I plan to do is to make many websites based on Drupal core.
All of these websites will be quite small, but there will be many of them (in matter of hundreds).
I'm working on this with one HTML / CSS coder, guy who should make themes for every website we make.
He doesn't know much of a PHP (enough for PHPTemplateEngine tho) therefor I what I want is to make as little interaction between me and him as possible. He shouldn't touch PHP part of themes, I shouldn't touch HTML part of themes.
My question is:
Can you tell me what structure of theme folder should I use, what's your opinion of Zen theme for beginning of Drupal theming and how can I make automatic JavaScript and CSS loading script for themes?
Also I'd greatly appreciate any tips concerning multi-site Drupal setup, best practices and so on.
Thanks in advance.
With regards to drupal theming you have a couple of options:
If all the themes will share 98% of the same code base and just have different classes etc to style it visually different (say a different heading colour), then you can get away with one drupal theme and use theme settings to alter the configuration of the theme on each site. This has the advantage of having to maintain only one code base. Zen can still be used as a base theme if you wish
Another option is one you have mentioned above, in which you have a base theme which declares all inherited code, and sub themes to which override specific parts of the base theme to create the necessary effects. I would suggest that this is the better option if your themes vary wildly from one site to another. There is a administrative burden with this option though, as say you have 100 sites, you could potentially have 100 sub-themes to maintain and provide fixes for.

What do you prefer ? Writing a Wordpress plugin or child theme?

What think to be consider when you prefer coding a solution in form of child theme rather then in form of a plugin ?
Themes and plugins solve different problems: plugins are for business logic, themes for presentation. They are not interchangeable. I prefer the right tool for the right job. :)
i prefer in child theme (or in function.php), rather then in form of plugin. It's more easy to reuse. You can just move it from one theme to another.
Any generic functions should be in a plugin. That way, they are available to all themes, and if you make changes in one place, you don't have to copy and paste to several files.
The benefit of a child theme is that you can make changes to an existing theme, such as twentyten, without directly modifying the source code, which is fragile -- it can cause errors and has to be repeated every time the theme is updated.
Depends on the situation. If it's something that could readily be used by any (or many) different sites regardless of the theme, I do a plugin.
If it's something specific to This Particular Site Only, I would probably put it in the child theme's functions.php. Even if specific to the one particular site only, I might make it a plugin if it's something I might want to turn on and off later.
Other than the fact that you can turn plugins on and off, there is little if any difference between code in a plugin and code in functions.php.
If it's something most easily coded straight into the theme (e.g. a particular permutation of the_loop) then of course just do it in the theme template and put supporting code in functions.php

Resources