Any way to know if another developer is editing the same files? - wordpress

I am working with my teammates on the same WordPress project, but once in a while we face overriding each other's codes, mainly in functions.php or style.css files. I was wondering if there is any away to avoid such problems?

once a while we face overriding our codes by each other
When we fix or add something we may not like to first ask about 2 minutes
for something that is done in just 5 minutes. But this gets a problem when multiple persons may work on same file and do not communicate about their work.
Is there a way to know if someone else is editing same functions
You can use any of below ways:
Recommended: use any sub-version control system like Git or SVN, and work only on your own branch (i.e. create a branch even for a single method/function and merge latter, but you also need to communicate about like: will create a branch and work on ...).
You could use an IDE that has a plugin that adds the feature to show other developers actions (e.g. a separate text-cursor with remote-Developer's name above it, like "Google documents").
For example, VS Code has the so-called "Live share" extension:
https://code.visualstudio.com/learn/collaboration/live-share
Or, develop a plugin that does add such feature to your IDE, as most IDE's provide SDK.
Actively use communication method's in an advanced way (e.g. like working on exactly some file over LAN, some software do support that).

Related

Oxygen Builder multiple users simultaneously

is there a possible way to work simultaneously with multiple users on a Website without overwritting the global styles. When I'm saving my changes and defining some new CSS classes they always disappear after my partner saves his changes also.
Is there a possible way to avoid this problem?
Maybe we failed at the installation and made some mistakes.
According to Oxygen's site, they do support multi-user editing.
At a guess, it may be possible to apply your own hooks so things aren't auto-generated/saved. You'd essentially create your own plugin to overwrite the functions provided by Oxygen.
How that functions, I'm not sure, but it would require "manually updating" later.
Honestly, IMO, I wouldn't try to overwrite this functionality, but instead look into local environments instead. Create a copy of the site that all your devs can use on their local machine, and then move it on to a shared/dev/staging site.
TBH, I've found Oxygen to be a bit of a step back in the DevOps life cycle, since collaboration is a task now.
The official documentation recommend using a single tab when working with Oxygen to avoid issues where one tab is saving older data than another, resulting in overwriting your new changes. The same scenario can occur when two or more users are working in Oxygen at the same time.
We have developed the plugin to support multiple user simultaneously.
http://collaboration.docs.oxyrealm.com
The plugin will update data and design instantly between multiple tabs of Oxygen Editor. So the overwrite issue is resolved since the data to save will be same and synced between the oxygen editor

Corporate Intranet on IIS 7: Looking to Enhance Directory Listing

I am looking for the ability to enhance the appearance of the directory listing pages of a very basic corporate intranet I developed for use by our employees. I am using Windows Server 2012 R2, and the site is deployed in Internet Information Services.
I did not use anything like Visual Studio to create this, and I have already handwritten all of the CSS and HTML for the index page that serves as a jump-off point for the rest of the site so that users can get to the content they need; however, the directory listings pages where the users land leave quite a bit to be desired to say the least.
I just want to be able to add some quick styles to these directories, such as modifying the font family and perhaps the link styles. Nothing major, really. The site already functions perfectly for what it was designed to do, and has been for years. This is just something that's always kind of bugged me but I never devoted any time to it. I'd like to do that now. Ideally I'd be able to just add something in the web.config file like inline CSS, or perhaps link it to a .css file that will house the styles. The latter is probably preferred, actually, but any way is fine.
Any help is greatly appreciated. To get this out of the way early: yes, I have done lots and lots and lots of searching on this topic — I'm talking hours. I have not been able to find a solution that seems to meet my needs. I consider posting here as somewhat of a last resort because I understand that it's a free resource and users here are usually quick to let other users know when they didn't find a particular article that seems to offer the solution they're seeking — which is usually a result of not knowing exactly what keywords to use — and I don't want to waste anyone's time. Just know that I have tried everything I know to find the solution, and that I'm genuinely stumped and looking for help from some pros.
Thank you!
Since the directory page is not HTML, you can't directly style it with CSS. However, there are a few options for changing the way it looks.
Write a script to point to your own, custom-styled, directory page. See this forum thread for tips on how to do that and a sample script.
Create a custom page using this module that you can further customize yourself.
Use the DirectoryListing open source app, which allows for customization of the directory page.
Either one of those solutions should give you more control over how the directory page looks.

Techniques for building Drupal Modules Quickly?

I'm looking to see if anyone has any resources or tips for developing basic Drupal modules faster? Have you come up with anything to make your Module development faster?
The Drupal module documentation is kinda hard to understand and pretty massive. I'm wondering if anyone has simplified it and given techniques/tips for getting specific things done quickly. I'm currently looking for Drupal 6 and 7. Any help saving time will be greatly appreciated :-)
In general, I'd recommend picking up a copy of the Productive Programmer. There's nothing earth shattering in it, but there are lots of small tips that can increase your productivity incrementally.
For Drupal specifically, Pro Drupal Development and Pro Drupal 7 Development, though not focused strictly on speed of development, are indispensable.
Beyond that...
in the first place, if you don't have to, Don't Write Code
get familiar with the most commonly used hooks
learn to use Drush and Drush Make
learn to use Devel and Theme Developer modules
use the Schema module to generate your module's schema code, based on an existing table
use the Data module (+ this patch) to generate the code to expose your module's tables to Views
use the Form Builder module to generate form code
use Coder to learn the Drupal coding standards, which will help others help you
set up "quick searches" to allow you to quickly search api.drupal.org
learn the shortcuts in your IDE or text editor (I like Netbeans partially because of the Drupal plugin); print out a good cheatsheet
learn to use version control effectively
Well, there really no fast track to it. If you understand the Drupal API regarding module development (install, menus, blocks, forms, etc) you will grasp it. The hardest part I remember was wrapping my head around the menu system.
One thing that helped was taking simple modules and seeing how they worked, and problem solving my own solutions. Reading Pro Drupal Development helps too.
You basically need to have an understanding where to look (API function, hook, system... ) when you want to do X. There is really no need to memorize all hooks/functions in detail with all the arguments and stuff. That's something you can easily look up. Especially if you're using an IDE with I suggest (Using Netbeans myself).
Especially when you're altering stuff, try to develop some techniques to quickly figure out what code is responsible for the stuff you want to change. One example is to look at the hook_menu() definition of the module that does it and then check out the page callback and skim through the code. Things to look up: Are there hooks you can use, is it a form (if yes, what is the form_id, how is the form structured) and so on.
The best and maybe only way to get there (knowing where too look) is exercise. Every time you do something, you'll be faster the next time when you have to do something similar. I think what also helps is working on core/contrib modules together with others. You not only get to learn these modules better, you also learn how to read and understand code written by others better and you improve your own coding style.
Try to utilize proven, generic "building block" modules like Views, Flags, Panels, CCK/Field and so on. Then, the heavy lifting is done by these modules and you only need to provide the glue code to properly integrate them with your site. Might take a bit more time the first time you use these modules but you will likely save a lot time after that.
That having said, I'm not sure if the goal should be to build modules fast. I'd say the goal is to build modules better. Try to make them generic, secure, flexible, theme-able and so on with the goal to re-use these modules on the next site your building, when you need something similar.
The majority of basic drupal module development is copy and paste. If you use textmate, the Drupal bundle for it allows you to build up key bits of modules (menus, theming functions etc) just by point and click (as it contains most of the necessary code snippets; you just fill in your info).
Following the module building tutorials is good too; the truth is, if you spent 3 or 4 weeks doing it day in day out, and you already have some background in coding, you'll be just fine.
Gedit for Drupal will preconfigure the very good Gedit editor/IDE for you.
For example, a new module: create an empty module file mymodule.example. Enter that file.
module<tab> And it expands into a full, predefined module.
Or in any module: hook<tab> to see a list of available hooks. Choose e.g. menu<tab> and it expands to a full predefined hook_menu. With <tab> you can walk trough all the variable parts in that new hook, to fill in the details.
Drupal.rb Has a.o. a $ drupal generate module "modulename" command that opens an interactive shell, wich allows building scaffolds for modules. The templates from which these scaffolds are built, are overridable.

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.

Favorite Drupal tips or best practices? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Just wondering what tips or tricks you guys might have to share. As always with posts like this, please only one tip per post so they can be voted on independently.
I'll start: however you do your theming, you can use the mothership theme as a base theme for your theme to inherit from so that your markup will be a lot cleaner and less verbose.
use drush to install/update modules and do maintenance tasks.
if you use drupal you cannot go without it.
Before coding any custom feature in Drupal, make sure there isn't already a module for it.
Use the zen theme - not only it
makes theming easier, it also adds
CSS classes that reflect the state of
the website (like <body
class="not-front not-logged-in
page-node node-type-project-project
two-sidebars">) - makes it really
easy to customize your site.
Browse through Drupal Modules -
9 out of 10 chances you'll find what
you are looking for there - is it
safe and/or maintained - that is a
different question ;) But at least
you'll have a starting point.
When setting up a new site, we immediately create a blank custom module named after the site/project. This becomes the central place where to put all the small fixes/kludges/tweaks that pop up to solve all those minor change requests that are not really features and do not call for a full blown module (at first ;) - this module should be regularly reviewed and refactored to remove stuff that became obsolete or to pull out stuff that turned into a feature, thus deserving a full module on its own.
Same for themes - whatever theme we start our sites with, usually it will get modified quickly/immediately, so best to rename it to the site/project from the beginning.
The 'site module' complements the 'site theme', in that it contains the business/workflow/data related tweaks/manipulations that otherwise would end up cluttering the themes template.php file (which should really only contain theme specific stuff).
learn the views module in and out
Two pieces of advice:
Don't blindly use the first module that shares a name with what you want it to do. Often the first module "captures" the namespace for that feature, but another, less aptly named module will fulfill the functionality better.
Look around for a way to do what you want that includes CCK/Views integration. This is pretty apparently the future of Drupal, so a standalone module that does what you want it to do that competes with a views/CCK-dependent module will probably die out in the near future.
++ to Geshan's suggestion.
Use the backup and migrate module its helps you a lot.
The most powerful feature in Drupal, is it altering system. This manifests in two ways
The entire theming system
drupal_alter() (most commenly seens as hook_form_alter)
The reason why these things are so powerful, is that it enables you to alter drupal core functionality and alter how drupal renders different things without changing drupal core itself (or contributed modules).
This is probably one of the major reasons to Drupal's success, since it allows developers to customize Drupal to do exactly what they want, and still retain all of the progress being made to Drupal and contributed modules.
CCK + Views + Panels
I heard of people using internationalization features to change bits of text that they otherwise couldn't.
Install and use the devel module. Spend some time with it up front have a more intimate knowledge of how it can help you debug modules, theme development, etc.
I shared some tips in this presentation
http://www.slideshare.net/mirnazim/best-practices-for-drupal-developers-by-mir-nazim-drupal-camp-india-2008.
Note: Fonts in slideshare are F***ed up, its better to download.
Using /var/www for my web root, I create /var/www/sites and symlink my sites directory to it, and /var/www/files for robots.txt. It makes upgrading (in the absence of an SCM) less scary, just overwrite the /var/www/drupal folder with the new version and hit update.php.
Use a local copy of drupal for your development; it's much less of a pain to debug locally than over the WAN, and easier for you to use your site's code as a project in your IDE, which (may or may not, dep. on your IDE) provide you with code completion and easy access to your files. When you're done you can push the changes via ftp/scp, or using whatever SCM you are familiar with.
I use devel's dsm() function liberally, so i would recommend that module. It makes debugging-without-a-debugger (i.e. after prod. move) much less painful.
Also, Admin Menu makes administering your site much easier; it gives you dhtml popup menu access to all the admin pages, in a hierarchy, so there's only one click between you and most admin functions.
Use exportables, via ctools module or the built in ones for views, etc to get key configuration settings outside of the database and put them into version control. This will make moving updates and changes from one site to another a lot easier.
If you're not stuck with PHP5 or a non-mysql database, use Pressflow (http://pressflow.org) instead of stock Drupal. Pressflow is optimized for mysql+php5 and supports better caching setups as your site grows, such as putting Varnish in front of Drupal for anonymous users.
Use the $id variable in node.tpl.php to make themes allow things other than long vertical lists of content. For example, you could check whether $id is 1, and if so wrap the node in a div which puts it in a big highlight zone at the top right of the page. (This is useful when combined with the 'make sticky at top of lists' function.) Then you could have two columns some way lower down the page, containing $ids between 2 and 8 and 9 and 15.
Sometimes you might need to check something other than the $id number to determine which 'zone' to place a node into. In this case, it can be very helpful to do some of the checking in a hook_preprocess_node function (which you can place in your template.php file as themename_preprocess_node) which contains a static variable which you can use to store the result of checks on nodes which have already been shown on the page. For example, I use this to display a date heading above nodes providing a node of that date has not already been shown, like so:
if ($vars['teaser']) {
static $last_date;
$date = format_date($node->created, 'custom', 'l jS F');
if ( $date != $last_date ) {
$vars['show_date'] = TRUE;
$last_date = $date;
}
else {
$vars['show_date'] = FALSE;
}
}
Framework is another great module for beginning the development of a theme. Using it as a base theme, I was able to port an existing theme to Drupal within hours.
Panels3
Learn it, use it, master it. It makes your site highly dynamic.

Resources