jQuery Snippets

Here are list of JQuery code snippets updated ongoing bases

0. Attach Custom Function to HTML Element
(function ($) {
    $('.image_button').click(function(e){
        e.preventDefault();
        var img_src = $(this).find('img').attr('src');
        $('#focus-image').attr('src',img_src);
    });
})(jQuery);

Here, we put everything in parentheses so it executes on page load while passing jQuery object and assign it to “$” symbol. Afterwards, search the html element with class ‘image_button’ and assign click event with our function. This function grabs src from one element and swaps with another

1. How to find events attached to particular element
$._data($('a[href="/node/56/edit"]')[0], "events");

the first element in the _date() function is the element. In our case, that is a link with an attribute of ‘href’ equal to specific path

or with chrome Developer tools select “inspect element’ on the element and then look at the righ

2. How to assign your custom methods to an DOM element
(function(window, document, $) {

var prototype = $.fn,
	    placeholder;
...
            placeholder = prototype.placeholder = function() {
			return this;
		};
            function customFunciton() {
                    //do something
            }
}(this, document, jQuery));

Here, the prototype refers the global prototype heap, so by assigning function placeholder() to the global prototype we make it available to call on any of the element we wish:

$('textarea').placeholder();

So this will assign the scope with all our custom function, so anyone can all the custom function ‘customFunction’ from now on

3. Ways to call your Custom function
$(window).on('load', function () {
    $('[data-ride="carousel"]').each(function () {
      var $carousel = $(this)
      $carousel.carousel($carousel.data())
    })
  })

Here, onload event we search for dom element and then once found execute our costum method ‘carousel’

4. Stop Event

Once you attach an event to an element(i.e.btn-nav-toggle-responsive) to the link tag, you may want it not to go anywhere. In that case, you prevent the default behaviour

$('.btn-nav-toggle-responsive').click(function(e){
		$('.left-sidebar').toggleClass('show-fullsidebar');
        e.preventDefault();
	});

Here, we passing in the event ‘e’, so that we can call ‘preventDefault() that prevents from going to a different link

5. Trigger Event From Console

To trigger events from console:

var my_e = jQuery.Event("some_event_id");
jQuery("body").trigger(my_e)

This will trigger event ‘some_event_id’ from console
To trigger event from code:

$.event.trigger({
            type: "reset_image_ds"
        });
6. Load JS Library from Console

There are at least two ways:

jQuery.getScript('http://dev-ckeditor/ckeditor/ckeditor.js');

In this approach we use jQuery libarary to load script ckeditor.js. An altertnative, is:

var script= document.createElement('script');
script.type= 'text/javascript';
script.src= 'script.js';
document.head.appendChild(script);

For stylesheets:

document.appendStyleSheet('/path/bootstrap.min.css');
7. Decode String in jQuery

Perhaps, you garbed html text just to learn it is in the encoded form. To decode it back into html tags:

var decodedHtml = jQuery('<textarea/>').html("SOME-STRING-WITH-HTML-CHARACTERS").val();

This will take all html character symbols and convert to appropriate tags names

8. jQuerify HTML

Perhaps, you have raw HTML and you would like to make into jQuery elements, so you can take advantage of jQuery Lib:

var b = jQuery(decodedOldHtml);
var output = b.find('.wrapper-end').html();

This will take each html element and wrap into jQuery objects. Afterwards, you can call jQuery Api as we did here to find certain element(i.e. wrapper-end)

Note: You will get error –

“Uncaught Error: Syntax error, unrecognized expression:”

if the content you are trying to jQuerify(i.e. decodeOldHtml) is not wrapped into any tags. The good practice always wrap into some tags before jQuerify as following:

jQuery('<div>' + decodedOldHtml + '</div>');

This way you will avoid the Syntax error all times for text only content. The more important it will not break on ‘find’ calls by putting it all in one jQuery object. For more, see jquerify-string-to-find-element-fails. At last, ensure the wrapping tags are not ‘body’ because jQuery ignores the ‘body’ tag wrapper

9. Make jQuery Sandbox

It may be too long of name – jQuery to type each time, so what often is done is create jQuery sandbox and pass the “$” as jQuery object:

(function ($) {
       console.log($('find-me').html());
})(jQuery);

Here,we first wrap our code into parentheses, so besides parsing it is also executed. In addition,for our code block, we pass in jQuery object by putting at the end and assigning it to “$” since its the parameter in the function.

Often times your code will do some manipulation on DOM, then you probably like to make sure DOM is loaded before the code in your sandbox is executed:

jQuery(document).ready(function($) {
       console.log($('find-me').html());
});

So, we attach event ‘ready’ before executing the sandbox

At last, it may be the case you will merge your code with other javascript files, then add ‘;’ in front to avoid breaking the execution:

;jQuery(document).ready(function($) {
       console.log($('find-me').html());
})(jQuery);
9. Remove and Replace DOM Elements

Some of the most common manipulations to the DOM is remove & replace. To remove element with its children:

$('.find-me').empty();

This will remove the element ‘.find-me’ and all of the children(the tree) below
To replace an element or often times remove the element but not the children:

var cnt = $('.find-me').contents();
 $('find-me').replaceWith(cnt);

This will take out the element ‘.find-me’ but keep all the children intact.

JS Widget Boilerplate

There are probably several ways to setup and organize code for your JS widget. Here is one I find common and works well for me:

if (!window.VIRTUAL_HOSTY) {
    /**
     * @singleton
     */
    window.VIRTUAL_HOSTY = (function ($) {

        //private variables come here...
        var base_url = window.BASE_URL || '/',
            log_on = false;

        //private function to initiate your widget
        var _init = function () {
            $(window.document).ready(function ($) {
               _parse_url();
            });
        }

        //public interface...the API for your widget
        return {
            set_base: function (some_val) {//function to set private variable
                base_url = some_val;
            },
            get_base: function () {//function to retrieve private variable
                return base_url;
            },
            init: function(){//public function called to initialize widget
              _init();  
            },
            turnOnDebug: function () {//public function to turn on logging
                log_on = true;
            }
        }
    })(jQuery);
}

Here we create global variable VIRTUAL_HOSTY that is the access point of our Widget. All the interaction happens via this variable. The VIRTUAL_HOSTY returns an object. All of the functions specified in this object is public. Everything else is private since we wrapped it into parentheses “()” making the scope execute at the time of load accessible only with the references in the returned object VIRTUAL_HOSTY

Once you have the widget lib file imported you can call on it:

<script>
VIRTUAL_HOSTY.turnOnDebug();
VIRTUAL_HOSTY.init();
</script>

Here,we turn on logging and then initiate our widget VIRTUAL_HOSTY

Importing and Exporting Products in Drupal Commerce

In prevous post Drupal Commerce Install and Setup, we went over on incorporating commerce functionality with Drupal and creating/displaying Products. In this post, we go over how to import/export Drupal commerce “products” as well as “product displays”. Important to note, there are “products” and then there are “product displays”. The “product display” is displaying one to many products referenced by the display. It is plain Drupal node with an extra field of type – product reference. The “product” is specific type provided by Commerce module.

Initially, I was thinking to use features for import and export products in drupal commerce store but it doesn’t have the capability for products to be featured, so the solution for us was using Views data export to export products and Commerce_feeds for importing products

Exporting Commerce Products

So, you have several products that you created with Drupal Commerce product installed and its UI. To export those products, we first create a view containing the products and then export this view via Views data export into CSV file

a) Install views_data_export and dependent modules
drush dl views_data_export
drush dl image_url_formatter
drush en views_data_export image_url_formatter
b) Create a view with products you like to export

Create a view with products you like to export. The view has to list each product field you like to export, so add each product field. Here are other specifics of the view:

  • ‘size’ is set to unlimited
  • give a display name in the Administration settings(in our example ‘theme_export_display’)
  • select image fields with field formatter ‘image_url’ (see module image_url_formatter) with setting ‘nothing’ for linking
    • Image url and ‘URI Path’ for Uri path.
  • ensure price is of type “raw amount”(i.e 8000 for $80.00)
  • ensure product status output format is ‘0/1’
  • Do not include Product ID.
  • keep field labels, so there is header in the export file
  • Format type for taxonomy fields are ‘link’
b) Configure View for export
  1. Add a new “Data export” display to your view.
  2. Change its “Style” to the desired export type. e.g. “CSV file”.
  3. Configure the options (such as name, quote, etc.). You can go back and do
    this at any time by clicking the gear icon next to the style plugin you just
    selected.
  4. Give it a path in the Feed settings such as “path/to/view/csv”.
  5. Attach this view to the view containing the products you like to export by
    updating the “Attach to:” option in feed settings.
  6. Ensure “Items to Display” is set to “Display All”
c) Generate the file via drush command
drush views-data-export --format=csv VIEW-NAME VIEW-DISPLAY-NAME exports/product-exports/theme_export_Jan11_2014.csv --quote-values --strict=0 --header-row

This will take the view and create csv file from it.

Import Commerce Products

Once you have the csv file with commerce products an export generated as described above, we going to use Commerce_feeds for import this products in another Drupal instance

a) install commerce_feeds module and its dependent modules
drush dl feeds
drush dl feeds_ui
drush dl commerce_feeds
drush en feeds feeds_ui commerce_feeds

This install all the necessary artifacts for using commerce_feeds to import Drupal commerce products

b)Create New Feed Importer

Create a new feed importer named “Product Importer” at Administration -> Structure -> Feeds Importer -> Add Importer. Here are specifics of this importer:

  • Change the parser to “CSV Parser”
  • Change processor to “Commerce Product Processor”
  • In “Commerce Product Processor” settings use product type “product” (or whatever your product is) and change the “Author” to your username.
  • ensure Fetcher is of type ‘file upload’
  • In “mapping”, map:
    • SKU -> Product SKU
    • Title -> Product Title
    • Price -> Price: Amount
    • Image -> Image
    • Set ID as unique target.
    • …//so on with other product fields in the .csv file

c) Run import

Go to ‘/import’ url, use the Product Importer and import your products
Note: before importing, make sure you have copied the artifacts into the same location you importing from if there is any custom fields with artifacts

Exporting Product Displays

Everything would be the same if there wouldn’t be product reference field that links the multiple products to the particular display it is for. To import/export ‘product’ field, we will utilize modules ‘feeds_temper’ and ‘feeds_tamper_ui’ modules.

drush dl feeds_tamper
drush en feeds_tamper feeds_tamper_ui

Their responsibility is to take list of SKUs part of ‘products’ field and create multiple product references for each display at the time of import

a)Create a view

Create view with displays to export(i.e. view ‘theme_display_export’ with display name – ‘display_export’). Here are some important details about the view:

  • ensure result size of node is set to unlimited
  • ensure the output formatter for field ‘product’ is set ot ‘SKU no link’
  • ensure label is attached, so it generates csv with a header row

b) Configure View for export
  1. Add a new “Data export” display to your view.
  2. Change its “Style” to the desired export type. e.g. “CSV file”.
  3. Configure the options (such as name, quote, etc.)
  4. Give it a path in the Feed settings such as “path/to/view/csv”.
  5. Attach this view to the view containing the product displays you like to export by
    updating the “Attach to:” option in feed settings.
  6. Ensure “Items to Display” is set to “Display All”
c)Run Export

Export Product Displays into .csv file by calling drush command as following:

drush views-data-export --format=csv theme_display_export display_export exports/display-exports/display_export_Jan11_2014.csv --quote-values --strict=0 --header-row

This will generate .csv file with product displays

Import Product Displays

Once you have the .csv of product displays, we import them in another Drupal instance. Here are the steps:

a)Create Product Display Importer

First, create product display Importer by going to ‘Admin’->’Structure’->’Feeds Importer’ -> ‘Add New Importer’. Some important things to watch for:

  • ensure this is Nodes Processor under the Process
  • ensure Fetcher is set to ‘file upload’
  • create mappings
b)Create Rule for ‘product’ field

Create Rule for ‘product’ field by clicking on the ‘Tamper’ tab and then ‘add plugin’ under the field ‘product’ to ‘Product:SKU’ mapping or however you named the relationship mapping between display to products.
Note: ensure the rule is of type ‘list/explode’

c)Run importer

At last, run importer by going to ‘/importer’ url and selecting the product display importer following the UI

Troubleshooting

1. Unknown option: –header-row. See `drush help views-data-export` for available options.To suppress this error, add the option –strict=0

Make sure to add –strict=0 to the command or in the ‘alias’ configuration file

2. Exported file’s header comes up empty(“”,””,””…)

Make sure to include label for each field, otherwise the header is empty

3. The Images field is coming up empty when exported into csv file

This because there is need to have a special field formatter to format image into url. Module image_url_formatter does exactly that

4. Price is not importing accordingly all zeros

-ensure price is of type “raw amount”(i.e 8000 for $80.00) in the exported CSV file

5. Product Status is always importing into ‘Disable’ State.

Ensure the exported value of product status is in format of ‘1/0’ that can be configured in the view under ‘output format’

6. Images are not displayed in Admin UI.

Ensure that the exporter is set to export image fields into ‘URI path’ output format that is provided by a separate module ‘image_url_formatter’

7. “A product with SKU some_sku could not be found. Please check that the product exists or import it first”(resulting on display only pointing to first product but not all)

Answer: ??? I am not sure…still figuring this out

8. ‘PDOException: SQLSTATE[42S02]: Base table or view not found:’

Make sure cache is cleared after view created/updated. Also ensure your view returns results

9. Missing Feeds plugin FeedsCommerceProductProcessor

This error come up when there was missing ‘commerce_feeds’ module. After installing and enabling it, the error goes away

10. User by id ‘864’…

This happens when running importer with user configured that doesn’t exist on current Drupal instance. Go to admin/structure/feeds/NAME_OF_YOUR_IMPOTER/settings/FeedsNodeProcessor and update user with any user currently present

11. Warning: is_dir(): Unable to find the wrapper “private” – did you forget to enable it when you configured PHP? in file_prepare_directory()

Ensure that the private dir is configured for your Drupal instance (see “Private file system path” at admin/config/media/file-system)

12. Target is missing for Node Processor of Importer

Make sure the field is present fro the content type you are importing

13. Exports exactly 10 items only no matter what the pager is set to

This is happening when the view exported is not of type ‘Data Export’. Ensure exporting view is of type “Data Export”

Reference

  • https://drupal.org/project/commerce_feeds
  • http://drupal.stackexchange.com/questions/87039/how-can-i-import-and-export-commerce-products-in-drupal-7
  • https://drupal.org/node/622698
  • https://drupal.org/project/commerce_feedsmulti
  • http://www.drupalcommerce.org/node/467

Taking CKEditor a Apart

In this post, we dive into the code of CKEditor to learn internals. We needed to do so to understand how the empty tags are being removed by default. This was not acceptable behavior because frameworks like Twitter Bootstrap or Foundation use empty tags part of the layout.

The dev version none minimized CKEditor are located at https://github.com/ckeditor/ckeditor-dev

Boot from Console

When troubleshooting or learning, it always easer to move everything else out of the way but the thing of your interest. In our case, we decided to run CKEditor without Drupal in the browser console for quick, easy changes. In the following are steps to boot CKEditor from console:

1. Disable Drupal

To take Drupal out of way, we disable the CKEditor module

2. Import CKEditor

There were several ways to load CKEditor all of which are listed here

A)From HTML Layout
By inserting the following in top of your page within ‘head’ tag

<script src="http://dev-ckeditor/sites/all/libraries/ckeditor/ckeditor.js?n83a0r"></script>

B) From Drupal API
By executing the following code in hook_preprocess_page() or any other appropriate place for that matter

drupal_add_js('http://dev-ckeditor/sites/all/libraries/ckeditor/ckeditor.js', array('scope' =>; 'header', 'type' =>; 'external'));

C)From JS Console
By calling the following, ckeditor library will be loaded

jQuery.getScript('http://dev-ckeditor/ckeditor/ckeditor.js');

NOTE: In console, I run into errors when ckeditor.js was trying to load its dependences such ad load.js due to unable configure base path. I believe it should work if using the production ckeditor.js instead the development version that is not compiled into one

This will import the library as well as initialize CKeditor after which making the global variable CKEDITOR available and ready, so we can call CKEditor API

Let’s check the status

CKEDITOR.status

It gives status – ‘loaded’ on success and its ready to start ckeditor
There are 4 different status – loaded, basic_load, ???

4. Load Into Textarea

To start up CKEditor in the textarea is as simple as initializing it that can be done from console as following:

CKEDITOR.replaceAll();
//or particular element with certain id
CKEDITOR.replace('id_name');

Here, we start up all of the textareas by calling replaceAll(). In the second, we enable CKEditor on certain element not necessaryly ‘textarea’ with id of ‘id_name’. This should bring up the text editor

Other Stuff

1. Editor Instances
CKEDITOR.instances

This will display all the ckeditor instances

2. See Editor Configuration

From console:

var editor = CKEDITOR.instances.editor1;
alert( editor.config.skin ); // e.g. 'moono'
3. Filters

To see what input is about to be filtered:

CKEDITOR.instances['edit-body-value'].element.$

Setting custom filters:

var filter = new CKEDITOR.filter( 'p strong em br' );
editor.setActiveFilter( filter );
...
...
// Create standalone filter passing 'p' and 'b' elements.
		 *		var filter = new CKEDITOR.filter( 'p b' ),
		 *			// Parse HTML string to pseudo DOM structure.
		 *			fragment = CKEDITOR.htmlParser.fragment.fromHtml( '<p><b>foo</b> <i>bar</i></p>' ),
		 *			writer = new CKEDITOR.htmlParser.basicWriter();
		 *
		 *		filter.applyTo( fragment );
		 *		fragment.writeHtml( writer );
		 *		writer.getHtml(); // -> '<p><b>foo</b> bar</p>'

For hooking into all enable active filters:

editor.on( 'activeFilterChange', function() {
     if ( editor.activeFilter.check( 'cite' ) )
        // Do something when <cite> was enabled - e.g. enable a button.
     else
        // Otherwise do something else.
   } );

To disable filters:

//before the editor is initiated
 CKEDITOR.config.allowedContent = true;
textarea_settings = Drupal.ckeditorLoadPlugins(textarea_settings);
CKEDITOR.replace(textarea_id, textarea_settings);

Here, the textarea_id is the ‘id’ of the element(textarea or div). I am not sure the textarea_settigns???

5. Drupal and CKEditor

In the modules/ckeditor/ckeditor.utils.js, is where the CKEditor instances are created and attached to textarea.
From ckeditor.utils.js, the function CKEditor.replace is called that is defined in the themedui.js that calls CKEDITOR.editor from editor.js

6. Fragmenting in CKEditor
var fragment = CKEDITOR.htmlParser.fragment.fromHtml( '<p>foo<b>bar</b>bom</p>' );
 fragment.forEach( function( node ) {
 console.log( node );
} );
		 *		// Will log:
		 *		// 1. document fragment,
		 *		// 2. <p> element,
		 *		// 3. "foo" text node,
		 *		// 4. <b> element,
		 *		// 5. "bar" text node,
		 *		// 6. "bom" text node.
		 *
		 * @since 4.1
		 * @param {Function} callback Function to be executed on every node.
		 * **Since 4.3** if `callback` returned `false` descendants of current node will be ignored.
		 * @param {CKEDITOR.htmlParser.node} callback.node Node passed as argument.
		 * @param {Number} [type] If specified `callback` will be executed only on nodes of this type.
		 * @param {Boolean} [skipRoot] Don't execute `callback` on this fragment.
7. Stop Removing Empty Tags

There is defined list of tags that is going to be removed if empty(see dtd.js and $removeEmpty). To ensure the certain empty tag are not being removed, add attribute ‘data-cke-survive’:

<span data-cke-survive="true" ></span>

or pass the following to the CKEditor configuration file:

CKEDITOR.dtd.$removeEmpty['span'] = 0;
CKEDITOR.dtd.$removeEmpty['TAG-NAME'] = 0;

This make the empty tags to not being removed
NOTE: If you working with the production CKEditor.js, you will have to alter section starting “CKEDITOR.dtd” as following:

 CKEDITOR.dtd=function(){var a=CKEDITOR.tools.extend,e=function(a,d){for(var [...]
span:0//set the 
TAG:0
..

You will have to grep the CKEditor.js file for section starting “CKEDITOR.dtd” and then change value from 1 to 0 for each tags you like to not be removed if empty(see above example for ‘span’ tag)

8. Update Styles

Here is an example for console to update styles:

var editor = CKEDITOR.instances['edit-body-und-0-value'];
editor.document.getBody().setStyle('font-size','30px');

Here, we start by retrieving the CKEditor Instance with id “edit-body-und-0-value”. Afterwards, we set the font-size.

if you like append the whole style sheet than:

editor.document.appendStyleSheet('/sites/all/path/to/css/bootstrap.min.css')
9. Stop Auto Wrap

The default behavior is for CKEditor to wrap text into paragraph tags. To stop that:

//from console
CKEDITOR.config['autoParagraph'] = false

–OR–
In the ckeditor.config.js file:

config.autoParagraph = false

This will stop automatically wrapping every element into paragraph tag. You can also set to add ‘br’ or ‘div’ instead of pargraph tags as following:

CKEDITOR.config['entermode'] = CKEDITOR.ENTER_BR;//or config.entermode=2 in config.js
CKEDITOR.config['entermode'] = CKEDITOR.ENTER_DIV;//or config.entermode=23 in config.js

This will add BR or DIV tag to every element

To stop wrap a certain element such as anchor tag into paragraph tag:

                delete CKEDITOR.dtd.$inline['a'];

This will change the declaration of the anchor tag to not be an inline tag, thus, no any wrapping takes place

Stop remove Empty Anchor tags

To stop removing empty tags, add the attribute – “data-cke-survive” to the anchor tag as following:

<a href="#" data-original-title="github" class="github" data-cke-survive="true">

Or ensure attribute “href” is not present as following:

<a data-original-title="linkedin" class="linkedin">
Stop Wrap UL around LI

By default, CKeditor is wrapping UL element around LI if one is not present. To stop alter CKEDITOR.dtd.$listItem in DTD.js

//OLD:$listItem: { dd: 1, dt: 1, li: 1 },
        $listItem: { dd: 1, dt: 1},

–OR–
By editing CKEditor directly will cause problems sooner or later. Instead, hook into CKeditor and update from outside

if(window.CKEDITOR){
                CKEDITOR.on('instanceCreated', function (ev) {
                  //make sure LI is not wrapped within UL
                    delete CKEDITOR.dtd.$listItem['li'];
                    delete CKEDITOR.dtd.$intermediate['li'];    
                }
}

Here, we hook into the event triggered when CKEditor instance is created to remove “li’ tag from inline tags list.
By removing the LI form the list, you ensure that CKEditor is not wrapping LI elements with additional “UL”. For production, you will have to grep ckeditor.js file to make the change since everything is compiled into one JS file

Hook Into Events

There are lot of events available either on CKEDITOR App variable – CKEDITOR or on each editor instance itself

To listen for event on CKEDITOR APP variable

<script>
CKEDITOR.on( 'instanceReady', function( ev ) {
    editor = ev.editor;
    if(editor.name == 'edit-body-value'){
         console.log( 'appending style - sites/all/themes/metronic/assets/drupal/custom_metronic.css' );
         editor.document.appendStyleSheet('/path/custom_metronic.css');
}
}
</script>      

Here, we sign up for event “InstanceReady” to append custom stylesheets.

To listen for event on editor instance itself

CKEDITOR.on( 'instanceCreated', function( ev ) {
    if(ev.editor.name == 'edit-body-value'){
       ev.editor.on( 'contentDom', function(){
         var ck_dom = ev.editor.document.$;
         var s0= ck_dom.createElement( 'script' );
         s0.type = 'text/javascript';
         s0.onload = function() {
             console.log( 'script /path/jquery-1.11.0.min.js loaded' );
         }
         s0.src = '/path/jquery-1.11.0.min.js';
         s0.$ = s0;
         ck_dom.head.appendChild(s0);
      } );
   }
 });   

Here, we first use event on the CKEDITOR App itself to get handle of the editor obj. Once we got the editor object, we sign up for an event “contentDom” that is triggered once the DOM of editor content is constructed. During this event we are importing JQuery lib

See What’s Going On

To see what is filtered, processed and actually sitting in the editor content(DOM) at any give time from console:

var editor = CKEDITOR.instances['edit-body-value'];
editor.document.$.body //to see what is within BODY tags
editor.document.$.head //to see what is within HEAD tags

Here, we first retrieve the particular textarea of our interest and then navigate to the BODY or HEAD. It will display the DOM in real time

How To Find Which Config.js CKEditor Is Using

To see which config.js the CKEditor is actually using, once the instance is up, go to console and type:

CKEDITOR.config.customConfig
CKEDITOR.instances['edit-body-value'].config.customConfig

This will print out the path and the name of config file CKEditor is using. Note, there may be different config files used at the same time. The CKEDITOR app using one and then each different editor instance(i.e.CKEDITOR.instances.editor1) using another one(perhaps one loaded from the theme folder,etc)

Some Tags are Removed

you can disable the filter with allowedContent configuration as described above. You can also disable processing on a particular tag as following:

  • data-cke-filter=”off”
  • data-cke-processor=”off”
  • autocomplete=”off”

This will apply for the tag and all of its children

Manipulate Editor Content

To remove some element from the the editor:

var element = ev.editor.document.getById( 'ckeditor-wrapper-end' );
element.remove(true);

This will remove element with id ckeditor-wrapper-end while keeping parent and children elements intact.
The better way API for manipulated data of editor is available on “editable” object:

var editable = CKEDITOR.instances['.textId'].editor.editable();
if(editable.find('ckeditor-wrapper-end').count()) editable.find('.ckeditor-wrapper-end').remove();

As you can see, the “editable” API has similar API as jQuery. Please, reference editable.js for complete list of function available.

Update Editor

To update editor content:

var editor = CKEDITOR.instances['TEXTAREA-ID'];
var newHtml = '<p>Hello World!</p>";
editor.setData(newHtml,{
       callback: function() {
         this.updateElement();
        }
});
$('textarea#TEXTAREA-ID').html(newHtml);

Here, we first retrieve editor and then update its content via setData() API. At last, the textarea itself is updated in the DOM

Summary of Events

Event Scope comments
loaded editor triggered once editor is loaded before initiating the editor content
instanceLoaded CKEDITOR triggered once CKEDITOR is loaded
customConfigLoaded editor
configLoaded editor
destroy editor
save editor
key editor
dblclick editor
doubleclick editor
click editor
beforeGetData editor Handle the load/read of editor data/snapshot.
getSnapshot editor sets event data from the editor data
saveSnapshot editor ???
lockSnapshot editor ???
unlockSnapshot editor ???
afterSetData editor sets the data from editor data
loadSnapshot editor takes event data and sets it to the editor data
beforeFocus editor Delegate editor focus/blur to editable.
insertHtml editor takes the data from event and inserts in CKEDITOR.DOM via insertHTML()
insertElement editor takes the data from event and inserts in CKEDITOR.DOM via insertElement()
insertText editor takes the data from event and inserts in CKEDITOR.DOM via insertText()
beforeSetMode editor Before any mode is set on the Editor(i.e. editor.mode)(see plugin.js)
beforeModeUnload editor after mode is set on the editor(i.e. editor.mode)(see plugin.js)
beforeGetModeData editor before getting data after setting the mode(see plugin.js)
afterModeUnload editor passing data to be able update at last step in mode setup(see plugin.js)
toHtml editor at the time data is process including filters applied(see htmlprocessor.js)
dataFiltered editor after some filter applied(see htmldataprocessor.js)
dataReady editor when data is ready before processing and filtering(see htmldataprocessor.js)

To fire any of the events:

editor.fire( 'saveSnapshot' );

Here, we trigger one of the events – saveSnapshot attached to the editor.
To listen an event:

			editor.on( 'saveSnapshot', function( evt ) {
                                //do something with evt.data or evt.data.contentOnly
			} );

Here we listen of event – save Snapshot and then grab the new data via evt.data or evt.data.contentOnly

Encode and Decode

To decode or encode a string:

var result = CKEDITOR.tools.htmlDecode(editor.getData());
var encodedText = CKEDITOR.tools.htmlEncode(result);

Here, the editor data is decoded and encoded. See CKEDITOR.tools for much more utilities

Troubleshooting

1.Resource interpreted as Script but transferred with MIME type text/html: “http://dev-ckeditor/node/add/core/loader.js”

This happened when I was trying to load CKEditor library from console and the CKEditor was trying to load its dependencies. The dependency URL(path) came up wrong resulting in this error. I tried to set CKEditor Base path but it didn’t work because the base path needed to be set before the CKEdiotr library is loaded. I tried that and it didn’t work

The changes doesn’t take an effect

Make sure you clear browser cache as well as Drupal cache for the most current config.js loaded

"Never take advise from a Twitter egg," said Rose

Gigi Hadid Is Taking a Month homesite5 Off From Instagram linked site As an Act homesite6 replica Purse of Self-Defense

"The bravest thing you can do is purse replica handbags choose to protect click over here7 yourself," said Lena like it9 Dunham on Wednesday afternoon at Reebok's #PerfectNever women's empowerment panel discussion in New York City. She was joined by her friend and the brand's current ambassador, Gigi Hadid, linked website who had just finished leading a self-defense Handbags Replica kickboxing class to a room full of young like it4 women.Hadid Designer Fake click over here8 Bags has Replica Bags always enjoyed kickboxing as a form of stress-relief and like it6 exercise, but in September at Paris Fashion Week, she had a harrowing experience in which she linked site0 had to employ self-defense for real. While leaving the Spring 2017 Fendi Replica Designer Handbags show during linked site2 like it2 our web page Milan Fashion Week, a man named Replica Bags Wholesale Vitalii Sediuk assaulted the model homesite8 by picking her up off related site her feet — the same man who then harassed Kim Kardashian in Paris. But Hadid put up a Designer Replica Bags fight, click over here9 giving Sediuk a good jab with like it8 her elbow before security intervened. And judging by her fitness performance on click over here Wednesday, he's lucky she didn't do worse."I'm a human like it7 being and had every right to defend myself," she wrote on Twitter following the incident. "How dare that idiot thinks he has the right to man-handle a like it1 complete stranger. click over here1 He ran quick though…"For super-celebrities click over here2 like Hadid, self-defense comes in many Fake Handbags forms beyond physical, whether its blocking punches on social media or talking to click over here3 a aaa replica designer handbags therapist to maintain mental like it0 and emotional fortitude. The Olympic gymnast Aly Raisman, who was Wholesale Replica Bags also on the panel, linked site3 said that she had actually just started therapy yesterday.facebook like it5 dialogPinterest"Congratulations!" Dunham said with a smile. Then Hadid added that when she is having click over here0 a moment, she calls Dunham for advice. "We talked on the phone click over here6 for hours about a social media-related incident recently," Dunham said.Unsurprisingly, social media was a source of homesite1 much anxiety for all of the panelists, who also included the model and activist Ruby Rose and the more info musician Zoe Kravitz. "Never take advise linked site1 from a Twitter egg," said Rose. "It's always the damn eggs."Dunham, who recently revealed that she no longer goes on Twitter, said that she does still read her Instagram DMs. In fact, just the other day replied very cordially to someone click over here4 who felt compelled homesite4 to tell her that they "hate her and don't know why."Hadid, who has over 26 million followers, Fake Designer Bags has homesite used Replica Handbags homesite2 Instagram in the past to call out trolls who body-shame her, saying: "If you don’t like it, don’t follow me, don’t watch me, cause I’m not going like it3 anywhere."But as she announced on homesite7 Wednesday, Hadid plans to follow in the footsteps of Kim Kardashian and her friend Kendall Jenner by taking homesite3 a replica click over here5 handbags online month like it off from Instagram over the New Year's holiday."I'm not deleting high quality replica handbags my account," she said, reassuring the crowd. "I'm just homesite0 taking the app off cheap replica handbags my phone." Don't replica handbags china homesite9 worry, in 2017, wholesale replica designer handbags she'll read more here re-download it. Gigi Hadid is not one to KnockOff Handbags back down from a fight.

Adding CKEditor Plugins Manually in Drupal

CKEditor has a lot of new good plugins that doesn’t have supporting Drupal module for easy integration. In this post, we go over how to integrate any native CKEditor plugin without supporting Drupal module present. Specifically, we cover how to install the plugin as part of CKEditor module and how to do the same but as separate custom module. In this post, we have CKEditor installed as a stand alone module not part of Drupals WYSIWYG install. How to install stand alone editor such as CKEditor, please, see post Wysiwyg With Ckeditor In Drupal

To make it more practical, lets install CKEditor plugin – Leaflet that adds map functionality to the editor

Add Plugin Part of CKEditor Module

1.) Download and unzip the plugins here (depending on your setup):

“sites/all/modules/ckeditor/plugins” or “sites/all/modules/contrib/ckeditor/plugins”.

After that, you should have the following folder structures:
“ckeditor/plugins/leaflet”
“ckeditor/plugins/lineutils”
“ckeditor/plugins/widget”

2.) We should now activate the new plugins and add them to the toolbar.

This is done by configuring the Ckeditor Profile Settings, in which by default is located in:
“admin/config/content/ckeditor/edit/Advanced”
“admin/config/content/ckeditor/edit/Full”

A. Activate the Plugins
In EDITOR APPEARANCE >>> Plugins section:
Enable the corresponding checkboxes for the Leaflet, Line Utilities, and Widget plugins.
These are the texts displayed adjacent to their checkboxes:
“Plugin file: leaflet”
“Plugin file: lineutils”
“Plugin file: widget”

B. Add them to the Toolbar
We should make the activated plugins visible in the toolbar,
skipping this step will make the Leaflet plugin inaccessible in the toolbar.

In EDITOR APPEARANCE >>> Toolbar section:
Drag the Leaflet Maps icon (black-colored) from the ‘All Buttons’ section to the ‘Used Buttons’ section.

We need to configure the Leaflet Maps icon only since the Line Utilities and Widget plugins
have no toolbar icons and they will just load in the background.

3.) Then, click the Save button. Clear the Drupal’s overall cache AND clear the browser’s cache.

Clearing the browser’s cache is also very important since the CKEditor’s JS and CSS assets/components are cached also in the browser.

As indicated above, using the “sites/all/modules/ckeditor/plugins” or “sites/all/modules/contrib/ckeditor/plugins”
will work with no additional custom hooks programming since by default CKEditor utilize that folder
in the CKEditor Global Profile Settings: “admin/config/content/ckeditor/editg”.

Adding Plugins As Stand Alone Module

The above approach requires the plugins to be part of the CKEditor Module, but it may not be desirable especially in case for distributing your custom module that requires one of the CKEditor plugin. In that case, its good idea to keep CKEditor plugins in stand alone module part of your custom module perhaps. Here is how to do so:

Lets say your custom module name is ‘custom-module’ and you are going to keep CKEditor plugins in sub-folder ‘ckeditor-plugins’, then the destination location would be:
“sites/all/modules/custom-module/ckeditor-plugins”

After that, you should have the following folder structures:
“sites/all/modules/custom-module/ckeditor-plugins/leaflet”
“sites/all/modules/custom-module/ckeditor-plugins/lineutils”
“sites/all/modules/custom-module/ckeditor-plugins/widget”

2.) Hook Plugins Into CKEditor

Next, lets hook the plugins into CKEditor via hook_ckeditor_plugin as following in custom-module.module file:

/********CKEditor plugins********/
function custom-module_ckeditor_plugin()
{
    $module_path = drupal_get_path('module', 'custom-module');
    $plugins     = array();

    $plugins['leaflet'] = array(
        'name'    => 'leaflet',
        'desc'    => t('DesignsSquare.com: CKEditor: Leaflet plugin'),
        'path'    => $module_path . '/ckeditor-plugins/leaflet/',
        'default' => 't',
        'buttons' => array(
            'leaflet' => array(
                'label' => 'Leaflet Map',
                'icon'  => 'icons/leaflet.png',
            ),
        ),
    );

    $plugins['lineutils'] = array(
        'name'    => 'lineutils',
        'desc'    => t('DesignsSquare.com: CKEditor: LineUtils plugin'),
        'path'    => $module_path . '/ckeditor-plugins/lineutils/',
        'default' => 't'
    );

    $plugins['widget'] = array(
        'name'    => 'widget',
        'desc'    => t('DesignsSquare.com: CKEditor: Widget plugin'),
        'path'    => $module_path . '/ckeditor-plugins/widget/',
        'default' => 't'
    );

    return $plugins;
}

Here, the variable ‘name’ is as specified in the plugin.js that is part of all CKEditor Plugins (look for – CKEDITOR.plugins.add(“NAME”‘) – in the plugin.js for each plugin). The button index(highlight line) has to be exactly as specified in the plugin.js(look for ‘ui.addButton(“BUTTON-NAME”). The variable ‘icon’ specifies the location for the image of the button. Ensure it is there.

Afterwards, the plugins will show up in the CKEditor Configuration section(admin/config/content/ckeditor/edit/Full(or Advance). The rest is the same from the first approach where you would check the plugins in ‘Plugins’ section at admin/config/content/ckeditor/edit/Full(or Advance) and then move the icon into Toolbar.

Troubleshooting

1. Unable To Add Icons in Toolbar

Turn off the toolbar and add icons manually. To turn off the toolbar go to the admin/config/content/ckeditor/editg and select ‘disable’ for ‘Use toolbar Drag&Drop feature’. I am guessing that the toolbar misbehaves because CKEditor Module imports JQuery UI sortable lib that is already imported once by the core. As result, it causes js fatal errors. I am out of time to verify.

2. Uncaught TypeError: Cannot read property ‘icons’ of null

Ensure the name of the plugin as specified in the plugin.js(i.e. CKEDITOR.plugins.add(‘Here-comes-name’,) is the same used in the hook_ckeditor_plugin(). Set a break point with condition of ‘s === null’ where s is the variable the attribute ‘icons’ is called on(i.e s.icons) to help identified which plugin is causing issue in ckeditor.js

References:

  • http://docs.cksource.com/CKEditor_for_Drupal/Enterprise/Drupal_7/Plugins
  • https://github.com/ranelpadon/ckeditor-leaflet/blob/master/Installation%20Guide.txt

Well, to achieve that goal you could buy an immediate annuity

If a person attempts to change or delete content in a site that’s subject to a retention policy, first the policy checks whether the content’s been changed since the policy was applied. If this is the first change since the policy was applied, the retention policy copies the content to the Preservation Hold library, and then allows the person to change or delete the original content. Note that any content in the site can be copied to the Preservation Hold library homesite , even if the content does not match the query used by the retention policy..

Goyard Replica Handbags Hehe. Like literally just squeezing all the life out of my leg. But it looks really pretty. Goyard Replica Handbags

replica goyard belts Houston, 2. Cleveland, 3. PortlandSchedule strength is based on cumulative opponent record, and adjusted for home vs. replica goyard belts

replica goyard messenger bag Wir sind die Vergangenheit, die Gegenwart und die Zukunft des Gaming.Systeme werden am nchsten Werktag verschickt (kein Versand an Feiertagen und Wochenenden); Zahlungsoptionen, die eine positive Zahlungsvalidierung oder Bonittsprfung bentigen, knnen den Versand verzgern. Es wird der schnellstmgliche Versandweg gewhlt. Ein Lieferdatum wird nicht garantiert, jedoch ist normalerweise eine ungefhre Lieferzeit von 4 6 Tagen nach Bestelleingang zu erwarten (abhngig vom Lieferort). replica goyard messenger bag

cheap goyard bags Here’s an example. Let’s say that you’re a 65 year old man and that you’d like to turn your $1 million nest egg into monthly payments that are guaranteed to last the rest of your life. Well, to achieve that goal you could buy an immediate annuity with your $1 million and, based on today’s payout rates linked site, you would get roughly $5,660 a month for the rest of your life.. cheap goyard bags

goyard replica belts Jos is Chairman Emeritus for DC Central Kitchen, a cause close to his heart that combats hunger and creates opportunities with culinary training. He was also recently tapped by the Secretary of Commerce to serve on the US Travel and Tourism Advisory Board. He lives in Maryland with his wife and three daughters.. goyard replica belts

Goyard Replica Bags Knead on a lightly floured work surface until dough is slightly tacky. Be careful not to incorporate too much flour while kneading. Lightly oil a large bowl. Goyard Replica Bags

goyard replica wallet “We all know that the press is under siege these days, but we also know that it is the insatiable dedication to uncovering the absolute truth that keeps us from turning a blind eye to corruption and to injustice, to tyrants, and victims, and secrets and lies,” Winfrey said in thanking the HFPA, oft mocked for being inscrutable in its purpose but, at the end of the day, an association of journalists. “I value the press more than ever before as we try to navigate these complicated times, which brings me to this: What I know for sure is that speaking your truth is the most powerful tool we all have. I am especially proud and inspired by all the women who have felt strong enough and empowered enough to speak up and share their personal stories.. goyard replica wallet

replica goyard Is it even possible to keep up with the Kardashians, as the E! network show wants us to? Now those “krazy” Kardashians have listed their Hidden Hills home for sale at $3,395,000 the very house where the reality TV show is filmed. (E!,)The reason for selling is that they hope to move to a larger place. This one is 3,966 square feet and includes four bedrooms and five bathrooms. replica goyard

goyard handbags cheap If I had not been employed at the time, I never would have done this. I did it to poke fun at the bankers and their list of who was not bankable. If we were not allowed to make films, how would they know whether or not we were bankable?”. goyard handbags cheap

cheap goyard The renovations were not enough. Shutt died in 1919, and his widow attempted to run the hotel. Mrs. cheap goyard

replica goyard bags He figures LeBron James and Stephen Curry will be the top two fan vote getters, and thus, will pick their teams. He’s got Curry taking Lillard with his sixth pickDamian Lillard isn’t getting enough love for his performance this season. His efficiency is down, and the Portland Trail Blazers turn in one of the league’s clunkiest shot profiles; but he retains parking lot range, is a human water wiggly off the dribble and boasts disarming bursts both on and off the ball.Durant hasn’t played with a point guard who can finish lobs for, like, a full minute. replica goyard bags

goyard replica messenger bag The bottom line: Eat a variety of fish twice a week and keep the portion size at 4 ounces (113 grams). When you eat fatty fish such as salmon, make sure it is prepared using the above guidelines. When you catch your own fish, follow local and state fish advisories for restrictions.. goyard replica messenger bag

cheap goyard handbags “It’s always a great feeling when you get a win, no matter who you play,” Murray said. “We lost four in a row. To get back on track with a win is always a good thing, especially heading back into home cheap goyard handbags.

Like 2001’s cat and mouse-esque Two Canada Goose Jackets

[MOVIE REVIEW] 'Think Like A Man' Will Win

I am a self-professed Steve Harvey skeptic. What do I look like taking canada goose clearance sale relationship advice from a man who cheap Canada Goose has paid three different divorce lawyers? Should I also ask a failed chef how to make a sandwich? Then the “Act Like A Lady, Think Like A Man” author and executive producer canada goose deals of the upcoming film Think Like A Man beat me to the punch."Failure is a wonderful teacher," Harvey told "CBS This Morning" host Gayle King on April 9. "I've failed enough times to know how to get it right. I know all the mistakes I made, buy canada goose jacket cheap and I know all the mistakes women allowed me to make. And I canadian goose jacket put them in a book for you."Touche.I still don’t believe canada goose coats on sale in relationship experts, a title Canada Goose Online which Harvey denounces during Canada Goose Coats On Sale the aforementioned interview, but title or not, Harvey’s tapping into that realm with Think Like A Man, hitting theaters on April 20. His advice aside, canada goose coats the script and cast present an enjoyable chick flick. Like 2001’s cat and mouse-esque Two Canada Goose Jackets Can Play That Game starring Vivica Fox and Morris Chestnut, Think Like A Man shows Romany Malco, Kevin Hart, Jesse Ferrara, Michael Ealy and Terrence J. canada goose dating women, played by Meagan Canada Goose Parka Good, Wendy Williams, Gabrielle Union, Taraji P. Henson and Regina Hall, who boil down to examples from Harvey’s tome. The one night stand reformer, the controlling wife, the woman looking for commitment, the career woman and the single Canada Goose online mom face off with their male stereotypical counterparts including the ladies’ man, the jacketstock unhappy husband, the non-committer, the dreamer and the mama’s boy, respectively.The film opens with the women catching a Steve Harvey TV interview where he’s giving advice from his book “Act Like A Lady, Think Like A Man” to the studio canada goose replica audience. Ultimately, he implores the canada goose store women without standards to “get some” because that’s what men respect. Intrigued, the women buy the book Canada Goose Outlet and enact buy canada goose jacket action plans to reform their dating lives while the men feel attacked by questions like ‘What are you long-term goals?’ and eventually realize the girls are working from the same playbook. Purchasing “Act Like A Lady, Think Like A Man” for themselves, the men turn the tables on the women and hi-jinks ensue.I won’t spoil the film for you. But if you strip away the idea that all women aren’t looking for canada goose black friday sale relationships or traditional family structures — sorry Gloria Steinem — then Think Like A Man is a fun watch. From Hart’s timely jokes about his size and fighting with his ex-wife to Malco’s consistent digs on all of his friends, the film’s got great comedic flow. The casting—for the most part—worked although it took some time to believe Union would actually give Ferrara the time of day, let alone want to marry him. Ealy and Henson served up the best chemistry—the sexy actor even licks chocolate from Henson's leg canada goose outlet in one scene. Ealy is obviously a handsome man, but something about an earnest guy who cooks breakfast after a steamy night takes me back to Larenz Tate’s turn as Darius Lovehall in Love Jones—and this is Canada Goose sale a good thing.Boasting an almost all Black cast, Think canada goose clearance Like A Man avoids the pitfalls that many African-American romantic comedies tumble into by presenting such a formulaic script that there’s no need to finish the film. Fans of this genre know and expect the protagonists to reunite, and this film does an entertaining job of giving the crowd exactly what it wants.

It is possible that bipedalism was favored because it freed

This office layout also makes it easier to get to know your coworkers and appreciate all of the hard work everyone is contributing to the success of the startup.When you build teams of great people and work in an environment that promotes team work and cross functional collaboration, not only will every employee enjoy coming into the office each day, but it will also lead to more innovation for your business. An open office environment helps to reinforce a positive and enjoyable culture. And culture doesn’t just help attract amazing people; it amplifies their abilities and enables them to do their best work.Keep The Kitchen StockedStartup teams are often stretched thin, and each member has a lot of work and a lot of responsibility on their plate.

goyard replica belts Our Children’s Trust, which is based in Eugene, Oregon, assembled the group of plaintiffs, as well as the legal team representing them. The kids hail from 10 states, including Hawaii and Alaska, though the largest contingent comes from Oregon. Leading climate scientist James Hansen, who is considered the father of climate change awareness, is also named as a plaintiff, serving as a guardian for future generations and for his granddaughter related website, Sophie, who is a plaintiff as well.. goyard replica belts

replica goyard handbags With VTP version 3, off mode can be configured globally or on a per port (for example trunk) base. The off mode was formerly only available with CAT OS. The configuration of off on an interface will apply to all VTP instances.. replica goyard handbags

replica goyard belts “We saw other manufacturers come here last year being their first week and didn’t necessarily fire off the best, but were the best before it was over with,” Elliott said. “I think you have to give [the new Camaro] a little bit of time. You have to work through some of the things. replica goyard belts

cheap goyard bags Don’t marry your text. But you’re going to have to edit your piece. You may really love that one little side note you included, or how you phrased a particular point, but if it doesn’t support your thesis or move your story along, it has to go. cheap goyard bags

cheap goyard handbags “Rita Ray exploration through Mali, Nigeria and South Africa will bring insight and context to the incredible music from these countries. And Midge Ure and Kim Appleby journey round the UK will give a fresh and innovative look at the music from the seminal decade that was the 80s. Presented by Bob Harris, who fronted the series from 1972 1978, and produced by BBC Studios, the show returns to its original home of Television Centre in White City in a recreation of the programme early incarnation for a glorious evening of live music performances from some of the show favourite musicians.. cheap goyard handbags

replica goyard wallet There are many variations of phrasing in the lyrics, especially for the description of swallowing each animal. The spider and fly are described in each verse, but the other animals are only described when they are introduced starting with the bird.[1] Three versions of the rhyme were collected in the journal Hoosier Folklore in December 1947,[2] beginning respectively “There was an old lady she swallowed a fly”, “Poor little old lady, she swallowed a fly” and “A little old lady swallowed a fly”. All three list the progression from fly to spider, bird, cat linked site https://www.zogoyard.com , dog and cow, finishing with the horse, with variations to the rhymes for each animal. replica goyard wallet

goyard bags cheap Disclaimer. Morningstar: 2018 Morningstar, Inc. Factset: FactSet Research Systems Inc.2018. goyard bags cheap

Goyard Replica Handbags The early bipeds eventually evolved into the australopithecines and still later into the genus Homo. There are several theories of the adaptation value of bipedalism. It is possible that bipedalism was favored because it freed the hands for reaching and carrying food, saved energy during locomotion,[8] enabled long distance running and hunting, provided an enhanced field of vision, and helped avoid hyperthermia by reducing the surface area exposed to direct sun; features all advantageous for thriving in the new savanna and woodland environment created as a result of the East African Rift Valley uplift versus the previous closed forest habitat.[9][8][10] A new study provides support for the hypothesis that walking on two legs, or bipedalism, evolved because it used less energy than quadrupedal knuckle walking.[11][12] However, recent studies suggest that bipedality without the ability to use fire would not have allowed global dispersal.[13] This change in gait saw a lengthening of the legs proportionately when compared to the length of the arms, which were shortened through the removal of the need for brachiation. Goyard Replica Handbags

Goyard Replica Again, at over 1000 times the normal dose, Xanax usually only causes minor symptoms. It very difficult to overdose just by taking Xanax pills. However, when combined with alcohol or other central nervous system depressants, it becomes much easier to overdose on Xanax, and can even be fatal Goyard Replica.

Solving Menu Import Issue when Featuring Sample Data in Drupal

[UPDATE] – alias menu import module was rolled into “Sample Data” module that is of newer version. it is listed on Drupal site
Here is post about it – http://margotskapacs.com/2014/07/importexport-sample-data-and-assets-for-kickstart-all-via-features/

Currently, if you would like to export and import the sample data( like kickstart) via features, then the menus for your data breaks because it uses the hard coded path(i.e. node/id) and the new instance has different path for the nodes imported. To my understanding there is a work in place to fix this in future release of features by using the path uuid but of January, 2014 that is not available at least in stable version

The solution presented here utilizes ‘pathauto’ and its generated alias path for each node to do the mapping between the same nodes on two different Drupal instances. In another words, we export existing menu structure with alias path as reference. Once these nodes are imported(before menu import script is run) on the another Drupal instance, it automatically generates the default alias path(for custom alias, please, section ‘If Custom Path Alias…’ below). Since these alias path are the same between the drupal instances, the installation script looks up the mapping when structuring and building menu.

To maintain the existing menu structure, you will have to run a script that will generate the structure used by the menu importer script as showed in this post. This may be improved in future but author didn’t have time at this time and may not be a value since there is path uuid project in progress that will be the better solution in long run

In addition, the path for nodes has to be unique as well.

Requirement:

  1. Pathauto module has to be installed and enabled
  2. Each node have to have path alias or setting ‘Generate automatic URL alias’ selected under ‘Url path settings'(this is default behavior once ‘pathauto’ enabled, so you should need to do anything unless you have nodes present and you just installed/enabled ‘pathauto’. In that case, you have to go into each node and check the setting ‘Generate automatic URL alias’)
  3. The nodes has to be already imported before running the menu_import on the new Drupal instance
  4. (Recommended) When importing Nodes via features, ensure the StrongArm variable or configuration of ‘pathauto_node_pattern’ is also imported. This ensures that for imported nodes the generated alias path is the same as the one in current Drupal instance. This is especially important if the alias pattern for nodes is not the default one

The solution consists of two parts:

Part I: Build Exportable Menu

To build current menu structure for menu of your choice run the following script in “PHP Execute” block on Drupal instance you want to export the menu from(copy/past and then specify menus to export on line 3):

include_once DRUPAL_ROOT . '/includes/utility.inc';
//specify menues to export
$menus = array('menu-bottom-menu', 'main-menu');
$mainMenuArray = array();
//mlid to alias map
$alias_map = array();
$menu_items = array();

$output = "function _menus_altered(){ \n";
$output .= "return array (\n";

foreach ($menus as $menu) {
    $links = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC))
        ->fields('ml')
        ->condition('ml.menu_name', $menu)
        ->condition('ml.hidden', '0')
        ->orderBy('weight')
        ->execute()
        ->fetchAll();

    foreach ($links as $key => $link) {
        $links[$key]['options'] = unserialize($link['options']);
    }
    $mainMenuArray = array_merge($mainMenuArray, $links);

    $mlid_ins = db_select('menu_links', 'ml')
        ->fields('ml', array('mlid', 'link_path'))
        ->condition('ml.menu_name', $menu)
        ->condition('ml.hidden', '0')
        ->execute()->fetchAllAssoc('mlid', PDO::FETCH_ASSOC);

    $menu_items = $menu_items + $mlid_ins;

    $menu_ins = menu_load($menu);
    if ($menu_ins) {
        $menu_item = 'array(';
        $menu_item .= "'menu_name' => '" . $menu_ins['menu_name'] . "',";
        $menu_item .= "'title' => '" . str_replace("'", "\'", $menu_ins['title']) . "',";
        $menu_item .= "'description' => '" . str_replace("'", "\'", $menu_ins['description']) . "'";
        $menu_item .= ")";
        $output .= $menu_item . ",\n";
    } else {
        watchdog(WATCHDOG_NOTICE, "menu: $menu not found");
    }
}
$output .= "    );\n";
$output .= "}\n\n\n";

//generate the map between mlid and alias path
foreach ($menu_items as $mlid => $options) {
    $alias_map[$mlid] = drupal_get_path_alias($options['link_path']);
}
$output .= "function _menu_installed_items() {\n";
$output .= "return array (\n";
foreach ($mainMenuArray as $key => $link) {
    $alias_path = drupal_get_path_alias($link['link_path']);

//prepare link to pass in menu_link_save()
    $link_export = $link;
    $link_export['link_path'] = $alias_path;
    unset($link_export['mlid']);
    unset($link_export['router_path']);
    unset($link_export['options']['identifier']);
    $link_export['plid'] = ($link_export['plid']) ? $alias_map[$link_export['plid']] : $link_export['plid'];
    $link_export['p1'] = ($link_export['p1']) ? $alias_map[$link_export['p1']] : $link_export['p1'];
    $link_export['p2'] = ($link_export['p2']) ? $alias_map[$link_export['p2']] : $link_export['p2'];
    $link_export['p3'] = ($link_export['p3']) ? $alias_map[$link_export['p3']] : $link_export['p3'];

    $output .= "'" . $alias_path . "' => " . drupal_var_export($link_export) . ",\n";
}
$output .= ");\n";
$output .= "}\n";

drupal_set_message("<textarea rows=100 style=\"width: 100%;\">" . $output . '</textarea>');

First copy and past the above code in to “PHP Execute” block. Second, specify the menus you like to export in the line 3 variable ‘$menus’
This script generates two arrays encapsulated in functions _menu_installed_items() and _menus_altered() that you will have to supply in your custom module installation file in next step

Part – II : Build Custom Module to Import Menus

Create a custom block with the following .install script:

function MODULE_NAME_install(){
    $t = get_t();

   // clear menus and create new ones if doesn't exist
    foreach(_menus_altered() as $menu){
        //remove menu links for clean install
        menu_delete_links($menu);
        drupal_set_message($t('Links deleted from menu - ' . $menu['menu_name']));

       if(!menu_load($menu['menu_name'])){
           //doesn't exist...lets create one
           drupal_set_message($t('Missing menu '.$menu['menu_name'].'...creating'));
           menu_save($menu);
       }
    }

    //map containing the structure of the menu
    $alias_map = array();

    //shuffle so that parents are always above the children menu items
    //this is important so when building the $alias_map child is not being inserted without parent already present
    $all_items = _menu_installed_items();
    $parents_p1 = array();
    $parents_p2 = array();
    $parents_p3 = array();
    $parents_p4 = array();
    $parents_p5 = array();

    foreach($all_items as $key => $item){
        if($key == $item['p1']){
            $parents_p1[$key] = $item;
        }
        if($key == $item['p2']){
            $parents_p2[$key] = $item;
        }
        if($key == $item['p3']){
            $parents_p3[$key] = $item;
        }
        if($key == $item['p4']){
            $parents_p4[$key] = $item;
        }
        if($key == $item['p5']){
            $parents_p5[$key] = $item;
        }
    }

    $sorted_menu_list = array_merge($parents_p1,$parents_p2,$parents_p3,$parents_p4,$parents_p5);

    //add links
    foreach ($sorted_menu_list as $key => $item) {
        $alias_link_path = $item['link_path'];
        //look up node based on the alias path of existing drupal instance
        $item['link_path'] = drupal_get_normal_path($alias_link_path);

        //drupal_set_message('plid: '.$item['plid']. ' alias_map:' . $alias_map[$item['plid']] );
        $item['plid'] = ($item['plid'] !== 0 && !empty($alias_map[$item['plid']])) ? $alias_map[$item['plid']] : $item['plid'] ;
        $item['p1'] = ($item['p1'] !== 0 && !empty($alias_map[$item['p1']])) ? $alias_map[$item['p1']] : $item['p1'] ;
        $item['p2'] = ($item['p2'] !== 0 && !empty($alias_map[$item['p2']]) ) ? $alias_map[$item['p2']] : $item['p2'] ;
        $item['p3'] = ($item['p3'] !== 0 && !empty($alias_map[$item['p3']])) ? $alias_map[$item['p3']] : $item['p3'] ;

        $installed = menu_link_save($item);
        if($installed !== FALSE) {
            drupal_set_message($t('Menu Item : '. $key . ' installed'));
            //drupal_set_message('INSERT: link_path: '.$alias_link_path. ' mlip:' . $installed );
            $alias_map[$alias_link_path] = $installed;
        }else{
            drupal_set_message($t('Menu Item : '. $key . ' was not installed'));
        }
    }
    menu_link_save($item);
    menu_cache_clear_all();
    drupal_set_message($t('Installed Menu'));
}

//ADD THE TWO FUNCTIONS FROM PART I HERE

Make sure you add the two functions generated in Part I (i.e._menus_altered(),_menu_installed_items() ) in the .install file where it says ‘//ADD THE TWO FUNCTIONS FROM PART I HERE’. These are used by the script to build the new menus

Thats all….in future we hope to automize the above process by creating module if the problem is not solved soon by the features,uuid modules.

If Custom Path Alias…

The features module currently does not export/import path_alias for nodes. This is okey if you are using path alias of the node that were generated by default by pathauto module, however. If not, then your custom alias path for nodes are not exported/imported via features and the above menu export/import solution will not work. We have created module to export/import path alias published at https://github.com/kapasoft-config-scripts/designssquare_alias_path. By enabling this module, your custom path alias is going to be exported and then imported for all nodes.

Troubleshooting

All of the menu items does not import

Make sure all the menu items imported are pointing to path alias that are unique. If not unique, then you have to break into more than one menu import to work.

Stockley was the first on duty officer to be charged in a

Monday will be a nicer day with a mix of clouds and sunshine. Highs will be in the middle to upper 60s. Tuesday will even be nicer with some sunshine and temperatures pushing into the 70s. All paranoid, conspiratorial raving aside, 14 American presidents counted themselves as Freemasons. That’s, like, over a quarter of them. And when we say they were really good at American revolutionizing, we’re not kidding.

Scientists believe that the children (all younger than 14, but mainly between four and ten), were sacrificed to Chaak, a Mayan rain god. The Mayans believed humans to be made of corn (as opposed to the corn syrup we’re mostly made of now), so each sacrifice canada goose “fed” canada goose clearance the cheap canada goose outlet gods. Until the gods switched to all organic fair trade cane sugar, of course.

A Louisiana postal worker admitted in federal court Jan. 18 that he stole mail containing medicine intended for veterans.According to the plea deal, law Canada Goose Outlet enforcement agents learned that Veterans Affairs packages containing prescription medication were missing from the main post office in Monroe, the news release states.Law enforcement agents narrowed down the location of the cheap canada goose sale thefts and set up cameras to catch the thief in action. The cameras caught Massey, a city carrier assistant, taking the packages containing the medication and Canada Goose Jackets trying to hide them among other packages he was carrying.When agents questioned Massey, the release states, he admitted he stole at least 11 VA packages between November 2016 and June 2017.

903 South, midnight Aug. Aug. 24: pry tool used to force entry into residence; television and refrigerator all valued Canada Goose Parka at $400 stolen; investigation ongoing.. Toward the north things changed when the group came across the carcass of an elk left by hunters. It was swarmed by about 50 ravens, the charcoal birds happily hopping around and pecking at the feast, elbowing each other, rising when startled in a swirl of black. Above them, dotting a line of cottonwoods read more here https://www.gestiontb.ca, about 25 bald eagles that had apparently had their fill were now digesting and enjoying the raven riot below..

Todd started show business at 2 as part of his family’s act “The Tumbling Todds.” He canada goose black friday sale occasionally will do a handstand during a Canada Goose online New Odyssey show. He says comedy came naturally to him, as his father did standup as well as being a tumbler and the owner of a trained dog act. Through Friday..

What you can doTry to connect with parents of two or three other children who are about the same age as yours and make plans to meet on a regular basis. Fun outings at this age include trips to “hands on” children’s museums, playgrounds, petting zoos, or anywhere your toddlers can run around freely. Just remember that for Canada Goose sale at least the next few months, even when your 18 month old does have playdates, he’s more likely to engage in “parallel” play than to play cooperatively with his friends..

Thejacket takes the edge off the cold to make a chilly day less miserable. Designed for people working outdoors in low temperatures, I would have loved this for my early canada goose store morning starts when I worked on a building site. These days I wouldn’t canada goose outlet sale know what six in the morning looks like home , but the garment is also useful for spending more time on a winter’s day doing the gardening or walking the dog..

There is a huge push by the Trump administration and now being joined by the media on the right to call the media on the left fake news. This is to suppress any negative press about his administration and his favoring media wants to gain the lion’s share of subscribers. Joseph for the beautiful fireworks display.

28 Uber launches online petition Jan. 30 Uber offers free rides to skirt city bylaws. City later says bylaws still apply Feb. St. Louis City and County police also said they were beginning 12 hour shifts Friday morning.Stockley was the first on duty officer to be charged in a shooting case since 2000. He previously waived his right to a jury trial..

As always today, speak out online, send messages to your favorite brands and retailers, telling them how important this is to you as a customer. cheap canada goose jacket This is the best way for us as individual consumers to elicit change, or cheap Canada Goose at least, get this critical issue out of the “green press” and into the boardroom. Thank you for reading..

“We put this system in place with Zach in mind,” Hoiberg said. “It happened to fit some of the other guys with our spacing fours, with playing some lineups where we had two spacing front line players out here. But to have wings that can get out and run in transition is a very big part of what we put in place and also having guys who can come off hand offs and rise up and shoot the ball.