Updating Drupal module - drupal

Every time I make significant changes to a Drupal module (i.e. new items in menu hook or changes to theme hook) I must go to admin/build/modules and click save again otherwise I cannot access the modifications I made.
Do you know if there is a better way to do that?
Thanks!

I would suggest drush and devel + admin which provides a much quicker way to doing mundane tasks like clearing cache.
These tools can save you countless hours when developing, once you learn how to use them. Drush is very capable and also provides shortcuts to installing modules and much more.

Altering menu items require a menu rebuild which can be triggered by going to the modules page.
You can also call functions like cache_clear_all and menu_router_build while developing.

Another useful tool to mention for precisely this problem (and general ease of getting around) is the Admin Menu. In the top left corner there's a useful and almost hidden set of options that include clearing caches - all at the same time or individually.

Related

Locating involved functions in WordPress

I'm looking at a site someone else developed. We're using a child theme that is calling back to a lot of its parent's functions. There are about two dozen plugins. Somewhere in there is a bug that's preventing a theme setting from propagating to the rendered page. The problem is, I am not sure what's involved.
I've tried enabling wp_debug, but the page is fairly silent. I've inserted HTML comments into functions and templates that I thought would be involved, but I haven't found one that is actually involved.
Is there a plugin or some way to force WordPress to log every file/function that's loaded for a page? How would you approach this scenario?
This is probably not the best answer, but I've dealt with a lot of similar situations on some of my customers who own WordPress websites.
I usually download the database and website locally and setup a local website using LocalWP, but you can use any web server like XAMPP or WAMP, actually. In the end, this is helpful, because I can quickly find apply functions of my hooks by doing a full-text search on the project.
To track down the error, I echo some logging with a helper function which will also print hook information.
If the code of your child theme is reached, this is a good start. If your website renders with the parent theme, you can focus on the hooks and calls in your child theme and hopefully you will find the error.
You really have to bite the bullet and follow the chain. If your parent theme renders anything you should be able to comment your child theme step by step to pinpoint the cause of the problem.

Do I have to Upgrade WordPress to "pro" if I want to edit the CSS?

I started using WordPress just a few hours ago because I need to develop a couple of blogs to a client. I understand that WordPress is the best solution if you want something fast but flexible. But, the first thing that I wanted to do was just change the font of the post and I didn't find how to do it (for all the posts, because I changed it on this one using the HTML editor). I've read something about editing the CSS, but it turns that I need to buy the Pro upgrade to be able to use the custom design.
Is this the same if I use WordPress in my server?
I need someone to guide me on this one. I need WordPress as customizable as it can be. But, I prefer not to pay! :) Unless that's the only way to do it.
If you use WordPress on your own server, you can do anything you like to it - it's open source. The "Pro" upgrade is just for WordPress blogs hosted on the commercial WordPress.com platform.
Do note that running your own installation means you're responsible for adding plugins, themes, keeping the code up-to-date, etc. That has a cost too, even if it's not money directly out of your pocket.
If you are using wordpress on your own server - you are free to do anything with it. The best way to customize your site then is using a child theme. It will contain your customization, overriding styles from previously loaded parent theme (and/or adding some scripts). You will be able to upgrade parent theme then without loosing your customization (until parent theme owners deprecate something you use, but it must not happen often). There are some plugins for simplifying working with it as well. There are also some easier customization ways, if you want just minor changes - such as Custom CSS in Jetpack plugin, which works in similar way, as far as I know.
If you're using a wordpress.com account, you have less freedom in modifying things, consider using paid custom CSS plugin maybe. Or maybe mentioned above jetpack will do.
Also, as mentioned in other answers - there are wordpress codex, wordpress.org forums, and wordpress stackexchange, they seem to be better place for such questions.
In your wordpress admin section of your site (usually www.yourdomain.com/wp-admin) on the left hand side nav bar, you will find a section called "appearance", if you expand this and click "editor" you can edit all of the files that your current theme uses. A quick warning, if you are doing this on a live server, the changes you make are live as soon as you save them!!
Hope this helps
I'm pretty sure you do not have to pay to customize CSS. Check your server installation... particularly in the folder $wordpress_install_home/wp-content/themes/default.
You should have access to all the CSS files in there.

Can I use views_bulk_operations with the Drupal 7 core toolbar module?

I'm building a drupal site right now where I'd prefer to use views_bulk_operations to administer the standard content overview (admin/content) and user overview pages (admin/people). My trouble is that I also want to use the toolbar module (or something like it) to give my site admins the ability to easily browse to the pages generated by views_bulk_operations (admin/content2 and admin/people2). It doesn't seem possible right now. The toolbar module automatically adds pre-defined links based on a users permissions, and there doesn't appear to be a way to make any changes to those links.
Any ideas? Or, perhaps, any alternatives to the core toolbar module? Thanks!
(I asked the same question here, but thought I'd have a better chance here on stackoverflow.)
I just figured out that I can use the quickbar module to accomplish what I want.

WordPress - Overriding a function in a plugin

I've been wonder for some time what the best practice is for modifying a plugin created by a WordPress user?
For example there are a couple lines of code I want to change within the Contact Form 7 plugin. The function is called function wpcf7_ajax_json_echo() and is located in:
wp-content > plugins > contact-form-7 > includes > controller.php
Of course I could just change the code right in that file and be done, but then I'm out of luck when I want to update that plugin as my modifications will probably get written over.
I know I should be making this happen via my functions.php file, but I'm not sure how to go about achieving this. Also, that particular function is 100+ lines of code and I'm guessing I don't want to overwrite that whole function, because there is a good chance the author of the plugin may choose to update something in that function in the future.
Does anyone know the cleanest way for me to modify a few lines within that function via my functions.php file?
Thank you!
I do not recommend changing the core. However, you are in a bit of a pickle.
You can:
Update the function code directly in the plugin
Copy the current function code from the plugin and override it in functions.php
In the end, you still run into the same problem - future compatibility.
Either:
The update will overwrite your plugin changes.
Your function overwrites the plugin changes.
So, as much as I don't want to say it, I'd update the plugin directly. At least then when you upgrade, you'll know pretty quick that your change is missing. Furthermore, it's possible the plugin updates will include your change.
You could use SVN if you wanted to maintain forwards compatibility (and your host has SVN available), whilst being able to keep your own changes.
Each plugin that's on the Plugin Directory has to have an SVN repo (that's how the Directory knows if there are updates). Here's the CF7 repo.
Checkout the trunk to your /plugins/ directory inside a folder like /custom-contact-form-7/. Alter the wp-contact-form-7.php file to give it a unique name, and make the changes you want to make to customise it.
To get new updates you can just svn up to get them, and they'll merge with your changes. Though, you may have to clean up merge conflicts sometimes.
Version Control with Subversion is the place everyone starts to learn SVN, if you need it. There's also a Github repo now, if you'd like to fork that.
I definitely think you should add your updates to functions.php or to a custom plugin. It's a hassle right now, but MUCH less hassle every time you upgrade the plugin.
You'll always have to reference the changes made in updates no matter what. Even if you're able to extend the functionality without copying this file, you'll have to at least check and make sure your changes still work. And WinDiff/BBEdit's compare will make quick work of that.
So my first suggestion is to override that function.
Second suggestion:
I noticed there's some extensions (a, b, c) to this plugin; perhaps you can find out how they made their extensions and use those details to make your own. Well, that's like suggesting you make a new house in order to fix the dripping faucet, but it's an idea.

Migating from CakePHP to Drupal, functionality question

(I've posted this on the drupal forum too btw)
I'm converting the company websites to use Drupal, or at least trying to check that its going to be the best way forward. I have a background in PHP development, and I'm currently using the CakePHP framwork. I've built this site (not my design) and I can see how to replicate most of the functionality using Drupal, most likely using the CCK module.
http://preview.tinyurl.com/yk6u8mt
As you can see from the homepage:
A user chooses a country.
The country is passed using an ajax call to a script that decides which phone is best based on 'in country' network coverage.
A div is shown recommending the visitor the best phone for that country.
I'm wondering how to go about this in Drupal, I'm definitely not after a step by step guide, I just want to know if this kind of thing is possible with Drupal, and what approach to use.
If someone can help that would be superb. Thanks.
Okay, so you've got a path you're defining in hook_menu, which is where your form is being presented - or else you've got it set up as a webform in a node, that could work too.
Either way, in your form you're going to be using AHAH - check out http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/6#ahah and http://drupal.org/node/348475 .
Basically, you're going to define another path in hook_menu that's of type MENU_CALLBACK, and which will receive the country as input, and then will return the div that you'll display on the screen.
One core example of AHAH that may be useful to you is where you're entering a password and it lets you know if the password is secure enough - check that out.
Edit: There's also some good examples at http://drupal.org/project/examples.
I would look into using CCK and views. you can set up filters for the views. If filters don't work, you have the ability to include php code. I have also successfully added jquery code in the header of a view through which I was then able to have my view filtered by what is typed in a text box.
Coming from CakePHP using Drupal is a pain in the a** - even more for developers.
It's application structure might be designed to ease extensibility but this only means you have a system to enable your own plugins and themes.
While modules are basically the M+C-part the themes are the V-part of an MVC-application. The problem is that this seperation is not very strict in Drupal - in fact you have to break it sometimes in order to make things work (e.g. you have to include a theme_mymodule_myfunction() into your module as default output which you then can override with your theme using mytheme_mymodule_myfunction() ) And don't even bother looking for classes ( see http://drupal.org/node/547518 ).
Also there is no real link from a module to a theme. On many occations this is a good thing as you can switch modules and themes seperatly without creating a problem. For application builders coming from CakePHP (or any other framework) you often feel a lack of "wholesomeness" - you create parts for a base software and have to live with it's drawbacks.
IMHO I wouldn't recommend this step. Drupal is fine if you have to manage a website and might add a few modules to add neccessary value (image gallery etc.) but I definetly don't recommend it as a base for a customized web-app.

Resources