Showing posts with label Features Module Drupal. Show all posts
Showing posts with label Features Module Drupal. Show all posts

Jul 10, 2013

Drupal Quick Tip: Issues using CkEditor and Wysiwyg with Drupal 7 (rendering Media (Vimeo,Youtube), version detection)



I am writing to all those who are frustrated just as me with the latest CkEditor version where it doesn't work as expected as the old versions, especially using Wysiwyg.


  1. One of the most common problem the developers are facing after installing the Wysiwyg module and uploading the Ckeditor Library into the sites/all/libraries directory is, the Wysiwyg doesn't detect the version of the uploaded CkEditor when you navigate to /admin/config/content/wysiwyg  (I am talking about the version 4.0 and greater)
"The version of CKEditor could not be detected."


one of the solution (which is a bad practice) is to edit the ckeditor.js file inside the
directory sites/all/libraries/ckeditor, you will have to find the version written in the file
probably in the first line i.e (version:"4.1") and replace it with a lesser than the 4.0th
version i.e (version:"3.6")


  1. Though the ^^^ above solves the Ckeditor detecting issue, this doesn’t work well with media embedding.
My simple solution for this is completely remove the latest version of your ckeditor and
re-upload the old but steady/reliable version of it (I prefer version 3.6.6.1)

Nov 17, 2012

, Drupal hooks : Basic Ajax request/response with Drupal 7 menu hook





Hello world!
This tutorial assumes that you are at least 50% familiar with drupal hook_menu()  and Jquery Ajax and I apologize in advance because I’ll be sticked with the topic and never come out of it. please post a comment below if you need more clarifications in any other areas not-related to the topic. Thank you.
 
My goal: Very simple!

  • I am having a HTML form with a textfield in a page.
  • Once the text field is filled and when the cursor moves/changes from it I need to pass the textfield value to my Drupal module with the use of AJAX and receive the response from it.
Step 1
  • In my module file I right the hook_menu()

Code:

/*

* Implementation of hook_menu()
*/
function mymodule_menu() {
$items['any/path/% ] = array(
  'page arguments' => array(2),
  'page callback' => 'myAnyFunction',
  'access arguments' => array('access content'),
  'type' => MENU_CALLBACK
 );
 return $items;
}


$items['any/path/% ] :  This is where you define a path, the “%” is the parameter meter that will be passed from the AJax request.

'page arguments' => array(2) :  You get the second argument of the path which is the ‘%’ (so “any” is 0 , “path” is 1, ‘%’ is 2).

'page callback' => 'myAnyFunction', : This is the function that will be triggered once the defined path is called, here is where we are going to right the response for Ajax.

'access arguments' => array('access content'):  This should be specified definitely when creating a module,if not you might get permission issues.

'type' => MENU_CALLBACK : Specify the menu type [checkout the ccomplte refrence here for menu types ]

return $items; You return the menu.

Step 2
  • And right the below Jquery with ajax request
Code:
jQuery(document).ready(function() {
$('#mytextfield').change(function() {

//Get the value of the textfield on change
var textfieldvalue= $('#mytextfield').val();

//pass the value to the url you created in the hook_menu();
path = '/customer/autofill/'+textfieldvalue;
$.ajax({
            url: path,
            method: 'POST', //you can make use of the GET method tooo
            success: function(data) { // recieve the response from the defined function
                        alert(data);
            }
            });
              false;
            });

Step 3
  • Now the response to the ajax to be written in the module file again
  • Can you remember this 'page callback' => 'myAnyFunction'  we wrote in step 1
  • So “myanyfunction” will be the function to respond the Ajax request

Code: 


//The $argument1 is the value passed by ajax and retrieved by hook_
menu() and again passed to the function
function myAnyFunction($argument1){

//This will be printed as the response

echo ‘Successfully received ’. $argument1;
}

Hmmmm..! are we done?
BOOOOM! yes we did it.

Note :  This is a very basic thing that you can do with AJAX and Drupal, there are more complicated things that you can deal with. I’ll be coming up with a very nice tutorial to do auto-fill fields using Ajax and Drupal 7 Database layer.
Please place your valuable comments below. Thnak you.

Stay tuned by following me in twitter








Aug 4, 2012

Drupal 7 + WYSIWYG + CkEditor | Install and configure




Before we start how to Install and configure Wysiwyg and CKEditor into your Drupal site , lets have a quick look about it?

What does WYSIWYG stands for?
It stands for What You See Is What You Get

Why do we use it?
WYSIWYG editors are used to generate the HTML code necessary for viewing web page content.

How useful they’re?
They are particularly useful for people with limited or no knowledge of HTML code in other words you do not need HTML tags to use.

As you create your content, the editor creates the code in background.

For example, if you want your text to appear in different colours, fonts in different sizes, all you need is to highlight the text and select the appropriate option from the tools available in the editor.

What is CKEditor?

CKEditor is a text editor to be used inside web pages. It's a WYSIWYG editor, which means that the text being edited on it looks as similar as possible to the results users have when publishing it. It brings to the web common editing features found on desktop editing applications like Microsoft Word and OpenOffice. 
This is the ideal editor for developers, created to provide easy and powerful solutions to their users.

Installation and Configurations
  • Download wysiwyg module from http://drupal.org/project/wysiwyg
  • Extract to your (modules sites/all/modules) directory
  • Then navigate to admin/config/content/wysiwyg to download the editor Library you want to install in your site
  • So, here I am going to select CKEditor
    • and I downloaded it from http://ckeditor.com/download
    • once the .zip file is downloaded extract the file and place it in sites/all/libraries folder
  • Go back again to admin/config/content/wysiwyg, now you’ll see the window as shown below in image 1.0

Image 1.0
  • Here is the place that I am going to select which input format is going to use the CKEditor/Wysiwyg
  • I’ll select the Filtered HTML format and hit “Save” (when the input format is selected to be filtered html I’ll be able to see the CKEditor whenever I create a block, node etc...)
  • ^^^ Even after the above step we’ll not find the needed icons or plugins in the editor, it will look simply plain

Image 2.0

  • Now you need to enable all the plugins that you need to appear in the CKEditor as shown in the Image 4.0 Navigate to admin/config/content/wysiwyg/profile/filtered_html/edit and expand the option “Buttons and Plugins” and check all the plugins that you wanted to appear in the Editor.
 
Image 3.0

  • We’ve done it! didn’t we ? check it for yourself , go and create a content , make sure the input format is “Filtered HTML" ------
    Boooom!
Image 4.0

Jul 16, 2011

Features Module Drupal

IMO Absolutely this module should be named as one of the core module in Drupal, This is the feature that we all (Drupal developers) were expecting when we were struggling to get the site 'live' from 'staging' or 'staging' from'development'. So here the most anticipated feature of Drupal developers.

What the module does ?
In a nutshell this module allows you to Import and Export Content types,Views,CCK Fields, Permissions, Roles, Menus etc... from one drupal site to another.

Step by step instructions
  • Download the module from : http://drupal.org/project/feature
  • Upload, Enable it in /admin/build/modules
  • After you enable the module you could see the 'Fetures' tab in 'Site Building ' menu or you can directly redirect to  /admin/build/features
  • Once you click on that tab or go to the admin/build/features link you might get into the features configurations page with two tabs 
    1. Manage
    2. Create feature
  • Click on 'Create feature'
    • Note : all the features that your going to create is going to be a separate module/ will export a different module.(you can get a clear picture of what I mean in the end of this chapter)
    •  In the 'Name' field give an appropriate name for your feature.
    • Then a 'Description'
    • Then the 'Version' such as 6.x-1.0,  6.x-1.0-beta1
    • (This is the normal structure of a module you write in the .info file See module development ) 
    • Leave the "URL of update XML" field for now 
    • In the "Edit components" dropdown list, select the component that you want to export             eg: Views
    • Once 'Views' is selected it will give you a  list of the views that you've created in /admin/build/views
    • Select the view you want to export (you can select multiple views)
    • If all set, then hit the 'Download feature' button and export your view(it will download as a zipped/tar/rar file as you download a module)
    • Now your done with exporting your view.
    • Note 2: Hope you understood why I said 'its a module' in the previous note
  •  Yipppi!!! we exported our view, and next is to import it to the other Drupal site where we need the same view.
    • Go to the other site and make sure the 'Features' module is Installed and enabled
    • Now untar the feature you downloaded and then upload it to your /sites/all/modules/ folder via FTP
    • Then click the 'Features' configuration page in the 'Site Building' menu or go to admin/build/features 
    • Click on 'Manage' 
    • You'll find the feature that you uploaded in the manage page. 
    • Simply check the chekcbox and enable the feature.
    • Hurrraaaay!!! the component you exported would be available for in your new site too
      • eg: If you have exported a view and uploaded in the other site, the view would have been created in your site by enabling it, you can still check it in /admin/build/views .
  • Enjoy Features module cheers :)