Drupal News

Syndicate content
Drupal related news with the junky stuff filtered out
Updated: 7 hours 11 min ago

.VDMi/Blog: Why does my file get removed after six hours?

April 8, 2014 - 11:29pm
My managed image got removed after a certain amount of time. How did that happen? After searching a bit I figure out.

The Form API has a form element called managed_file. It uploads a file and adds it to the managed files table. This way Drupal has knowledge about and control over it. But now I got the situation that after a certain amount of time the image got removed. It just disappeared. What is happening here?

Well the managed_file works with Ajax. To smooth the proces it adds the managed file and leaves the status on temporary until some one specifies 'this is my file its managed'. You do that by adding this snippet of code to your submit handler.

$file = file_load($form_state['values']['file_element_name']);

// Change status to permanent.
$file->status = FILE_STATUS_PERMANENT;

// Save.
file_save($file);

If you have your form managed by

system_settings_form()

you want to add a extra submit handler. You can do that this way.

$form['#submit'][] = 'extra_admin_submit';

Modules Unraveled: 103 Content Branching and Static Site Generation Using Zariz with Amitai Burstein - Modules Unraveled Podcast

April 8, 2014 - 9:00pm
Published: Wed, 04/09/14Download this episodeZariz
  • What is Zariz?
  • How did this come about?
  • How does it help content creators?
  • How is this different from Workbench Moderation, and the default revisioning system?
  • You mentioned that it duplicates nodes, how do the URLs stay in tact?
  • Talk a bit about how you can create static site from a Drupal site.
Use Cases
  • Content staging
  • Static site generation
    • What about authenticated users?
    • How does this help performance and scalability?
Questions from Twitter
  • Kate
    Is Zariz an alternative to drupal.org/project/sps?
Video

Screencast demo starts at about 40:23

Episode Links: Amitai on drupal.orgAmitai on TwitterZariz RepoTags: 

Fuse Interactive: Watch as I try to upgrade this module to Drupal 8. What happens next you won't BELIEVE!

April 8, 2014 - 5:05pm
Drupal 8 is coming with more API changes than ever before. Are you ready?? Prepare yourself by upgrading your first Drupal 8 module right here on the Fuse Interactive blog. Learn by doing and follow along as we explore the new Routing component, OOP Drupal, PSR autoloading... and more!

PreviousNext: Secure your infrastructure with Docker and Puppet.

April 8, 2014 - 4:10pm

I recently spoke at the Drupal Melbourne meetup about running Puppet and Docker to increase security for running multiple sites on the one host. It's alot of work to get setup properly for a remote speaker so I would like to thank the organisers for allowing me to present.

Metal Toad: Pond Life Ep.2

April 8, 2014 - 3:09pm

Hello Everyone!
Welcome back to the pond! Last week we touched on the importance of mentoring juniors and Github best practices. In this week's episode, we'll be following up on the junior workflow from last week by discussing two tools you should definitely have and how to install them, exploring new ground by touching on some entry level SCSS techniques, sharing my AHA! and FAIL moments of the week, and lastly, our weekly query for you good people out there to ponder. So lets jump right into it shall we?

DrupalCon Austin News: Symfony Community: A Special Invitation to DrupalCon Austin

April 8, 2014 - 11:49am


With the rapidly approaching release of Drupal 8, many Symfony developers may be considering going to Austin for DrupalCon in June. Our advice? Do it!

Julian Granger-Bevan: Improving SEO using Drupal Similar by Terms

April 8, 2014 - 8:00am

Search Engine Optimisation (SEO) is the process of altering your website to maximise the exposure of your website via search engines such as Google and Bing.

The aim is to bring more visitors to your website.

If your website is built using the Drupal CMS, this article will give you an easy tip that will both improve the experience for your visitors when they are on your site and help boost your search engine rankings.

The method is made easy using the Similar by Terms module for Drupal, and exploits the need for visitors to be able to find other relevant content when they are on your website.

Why use Similar by Terms?

Search engines such as Google are looking at hundreds of factors when they decide which pages to display prominently in search engine results pages (SERPs).

These factors include content, quality and context.

Your site is more likely to be placed highly in SERPS (leading to more traffic) if Google identifies that it is authoritative on a particular subject. Links around between pages on your website will help Google recognise the topic that each page on your website covers, and means that it is more likely to rank highly for that searches on that topic.

Do not get confused, this is not the same as link building from other websites (for which care needs to be taken as search engines will penalise you if these are unnatural).

Similar by Terms provides an automated means of displaying related content links on your website. It does this by comparing the taxonomy terms that each node is tagged with, and creating a simple ranking based on the overlapping terms  from which it can draw the top few nodes to show to your visitors as links.

Links to relevant content also improve the experience for your visitors, by giving them suggestions for what to read next. A visitor is much more likely to find links useful (and continue to browse your website) if the links are relevant to the page that they are already on.

How to install Similar by Terms

To install Similar by Terms, download the code from http://drupal.org/project/similarterms and enable on your website by visiting the /admin/modules page.

You will need to have also installed two dependencies: Chaos Tools Suite and Views.

Similar by Terms exposes a view to your website, and the next thing you will want to do is edit this to suit your needs. The view can be found at the page /admin/structure/views.

The default view is quite basic, and simply returns a list of the titles of the related nodes. You will likely want to edit this (perhaps to also show a teaser or image from the node). These edits can be made just like any other view.

One setting that is unique to Similar by Terms is the taxonomy vocabularies that are considered when ranking nodes for similarity. You can opt to include just one, or all of your vocabularies in the comparison.

To do this, click "Advanced" on the right hand side of the edit screen, then click on "Similar By Terms: Nid" in the contextual filters section.

Now a dialog appears where you can choose which vocabularies to use.

You can also create your own views utilising the functionality provided by Similar by Terms. Simply copy the relationships and sorting rules that exist in the default view that Similar by Terms provided.

One last hint

The default behaviour of Similar By Terms will only show nodes in the list that share one or more taxonomy terms with the node being viewed.

This means, that you might only see one related node, or even none at all.

For the styling of your website you're likely to want to always show the same number of nodes in the list. Whilst there is a feature request in the issues queue for this, there is a simple method that will solve this for you straight away.

The answer is to create a new taxonomy vocabulary called "Included in Similar By Terms", with a single term called "Included". Let that term default on all nodes on your website. This way, all nodes will have at least one taxonomy term in common, and the real similar nodes will rise to the top of the list above those that aren't really related.

Category: WebsitesTags: DrupalSimilar by TermsDrupal Planetrelated contenttutorialhow to

Mediacurrent: Running Drupal on OpenShift from Red Hat

April 8, 2014 - 7:52am

An interesting platform I came across recently for developing and deploying cloud applications is OpenShift by RedHat. OpenShift is a next generation application hosting platform. The software running this service is open-sourced under the name OpenShift Origin, and is available on GitHub. Developers use Git to deploy web applications in different languages to the platform.

Acquia: Using Composer Manager to get off the Island Now

April 8, 2014 - 7:28am

On the eve of 2013, prolific Drupal contributor Larry Garfield put forth a challenge to "get off the island", and judging by the adoption of non-Drupal projects in Drupal 8 core I would say the community has responded.

Phase2: Say Goodbye To menu_get_object() @NYC Camp

April 8, 2014 - 3:30am

Drupal 8 is bringing some great new features in addition to some fun DX changes. One of the ways I like to learn about these changes is to deconstruct the API.

The best way to deconstruct the API is to dive into code that has a certain purpose, like looking at the Breadcrumb API.

Since we know we’re focusing on Drupal 7 to Drupal 8 changes, we can also use the excellent documentation in the change records to help us.

In my upcoming NYCCamp presentation, I’ll review some of the common API functions we used in Drupal 7 and how they’ve changed in Drupal 8.

What Node Am I On?

A lot of custom blocks that show related content, connected taxonomy, or any other relationship to currently viewed page typically depend on menu_get_object(). I’m sad to say that our old friend is gone.

In Drupal 8, the way to get details about nodes are through the attributes of the request object in the global \Drupal namespace.

While the DX of this implementation is currently being discussed, as of this writing, to get details about the current node:

<?php $node = \Drupal::request()->attributes->get('node'); ?>

drupal_render() is EVERYTHING!

Consistency is a big theme (no pun intended) in Drupal 8. Render arrays are the main driver to staging content to be passed to the theme layer.

As such, the theme() function is now gone.

Instead, a new #theme array key is passed to build a piece of content programmatically.

For old core theme functions, like theme_table() or theme_link(), you can pass in the ‘table’ or ‘link’ keyword, respectively, to the #type array key.

As noted in the change record, to create a table of data with a pager, set the various keys, then pass it to drupal_render():

<?php // Theme is available as an element type (may have additional processing in rendering). $table = array( '#type' => 'table', '#header' => $header, '#rows' => $rows, '#attributes' => array( 'id' => 'my-module-table', ), ); $markup = drupal_render($table); // Pager is not an element type, use #theme directly. $pager = array('#theme' => 'pager'); $markup = drupal_render($pager); ?>

Want More?

If you can’t make it out to NYC, definitely look for me at either the upcoming Chicago Meetup or Drupalcon Austin!

I hope to you see in you in NYC this weekend!

Marek Sotak: Inline Manual 1.0 Drupal module released, show your clients how to use their site

April 8, 2014 - 2:03am

After few betas, Inline Manual Drupal module has reached stable 1.0 version. Throw screenshots, screencasts and word documents away! Be interactive and agile. :)

"Inline Manual is a service to create interactive, reusable and easy to maintain step-by-step documentation for end-users of a website or application. Be it a tutorial "How to add a new user" within a CMS you've just built or a tutorial showing how to manage specific content."

The Drupal module allows you to:

KnackForge: How we managed to send 75k emails per hour

April 8, 2014 - 12:42am

Ardent team at KnackForge always loves to get hands dirty with challenging projects. In this connection we recently took an interesting newsletter sending project from one of our potential clients who is doing relatively big in Internet marketing.

In brief, we were asked for a custom system for sending out newsletter emails, based on Drupal. Tentatively 600k emails to be sent per month. A newsletter list shall have up to 80k users and limited to a couple of lists to begin with.

Pronovix: Drupal Developer Days 2014 Szeged - behind the scenes

April 8, 2014 - 12:20am

Drupal Dev Days Szeged was a great opportunity for me to realize and take part in one of Kristof’s crazy ideas (well, almost as crazy as Drupalcon 2008 was ;) with some great people from the community. While the event turned out to be a success, I’ve learnt a lot that I would like to share with all future organizers through this blog post and other channels.

Morten.dk: Themer Survey 2014

April 7, 2014 - 8:25am

Dear Themer we the Drupaltwig group need some answers & advice from all of our fellow Drupalistas - We want to make sure that we are creating a theme system that lives up to the wishes of all Drupal8 users - but especially us themers ;)

read more

Stanford Web Services Blog: Overriding Open Framework Styles: Block styles, Sidebar Menus, and Regions

April 7, 2014 - 8:06am

In this post, I continue my series on how to override Open Framework's default styles to get a more custom look-and-feel on your site. Last time we looked at how to override our typography styles. Today, we'll look at a grab bag of other things, including block styles, sidebar menus, and region styles.

Fred Parke | The Web Developer: Create your own tokens in Drupal 7

April 7, 2014 - 7:58am

Tokens are a pretty powerful weapon to have in your arsenal, and they actually come in useful a lot if you remember that they're there.

If you haven't used them before, tokens are essentially text placeholders - they can be static text, variables, field values, whatever you want really.

The Token API is now part of Drupal 7 core and as it turns out, using it to create your own tokens is super easy - you just need a couple of hooks.

The first hook, hook_token_info(), is used to declare any custom tokens.

Appnovation Technologies: Accessibility in the Real World: Top 6 Automation Misses

April 7, 2014 - 7:25am
Making your work accessible shouldn’t be a optional deliverable; we have a duty of care to the real world of users to build this in as part of our work. No matter how good automated test tools are, they won't cover everything. Here are 6 points of consideration for accessibility.

Bryan Braun: Making Targeted Drupal Cache Clears using Drush

April 7, 2014 - 6:21am

The standard Drush command for clearing Drupal's cache looks like this:

drush cache-clear all

(You can also use the shortened alias cc like this: drush cc all)

These commands give you the same result as when you click that cache clear button in the UI — it clears all of Drupal's internal caches.

But clearing all of Drupal's caches at once can be overkill. You usually don't need to clear everything, and doing so can put heavy load on your servers (especially if your site is large or gets a lot of traffic). Beneath the surface, Drupal's caching is actually pretty granular, and tools like Drush give us the ability to target and clear caches on the subsystem level.

Using Drush, you can see your caching options with:

# Using the shortened alias from this point on. drush cc

Which returns something like this:

[0] : cancel [1] : all [2] : drush [3] : theme registry [4] : menu [5] : css+js [6] : block [7] : module list [8] : theme list [9] : registry ...

Let's look at what each of these does (as a quick note, I'm specifically looking at Drush 6, which is the major version at this time):

drush cc all
Remember how I said that this does the same thing as the cache clear button in the UI? Well, that's technically false. Yes, drush cc all will clear all your Drupal caches (as long as it can bootstrap Drupal), but it will also clear its own internal Drush cache. That's why when Drush cannot bootstrap Drupal, you will still see a success command saying 'drush' cache was cleared.

drush cc drush
This only clears Drush's internal cache (the same one I just mentioned). You don't need a Drupal site available to clear this cache.

drush cc theme registry
This command simply calls drupal_theme_rebuild() to rebuild the theming system. This is needed whenever new ".tpl.php" files or theme hooks are added to the system. This specific cache clear only applies for Drupal 7 and up.

drush cc menu
This runs a menu rebuild, which refreshes the database tables used by various menu functions. For example, any new router items (like those defined in hook_menu) are added to the menu_links table, and stale ones are removed. This also clears the page and block caches, to prevent the display of stale menu links.

drush cc css+js
If you have CSS or JS aggregation enabled, this will rebuild the aggregated files. It also increments the query string on CSS & JS links, forcing clients that have cached an old copy to download a fresh one.

drush cc block
Block caching exists so Drupal doesn't have to look up the locations and visibility of blocks with each page load. This command refreshes that cache.

drush cc module list
This re-scans the module directories in your codebase and refreshes Drupal's internal list of which modules are available.

drush cc theme list
This re-scans the theme directories in your codebase and refreshes Drupal's internal list of which themes are available.

drush cc registry
Drupal maintains an internal registry of all functions or classes in the system, allowing it to lazy-load code files as needed (reducing the amount of code that must be parsed on each request). The list of these files is known as the "code registry" and it is stored in the system table in your Drupal database. This cache clear will look at this list of files and update the contents of any files that have been changed. Note: it will not rebuild the registry from scratch. For more information, see registry_update.

drush cc ?????
You may see other options in this list, because contributed modules (like views and advanced aggregation) can add their own kinds of cache clears. In each case, you'll see a file in the contrib module named something like mymodule.drush.inc that contains the code which defines what the cache clear does.

 

If you want to see what each of these options does on a code level, you can download Drush and inspect the file found at Drush/commands/core/cache.drush.inc.

Wunderkraut blog: Drupal 8 and the slow death of IE8

April 7, 2014 - 4:02am

IE8 is resisting to die. Internet Explorer 8 world-wide usage is more popular than IE9 and even IE10

First, a small story.Once upon a time, in 2012, when Drupal 8 was going to support IE8, we added HTML5Shiv to Drupal core to support HTML5 elements in IE8 and old browsers. But during 2013 things happened. jQuery decided to split their library into: 
  • jQuery 1.x (IE8, IE7, IE6 support)
  • jQuery 2.x (IE9 support and newer)
Both branches have the same jQuery API. This situation, clearly pushed the Drupal core maintainers into a big decision: Should Drupal 8 core ship with jQuery 1.x or 2.x ?. Nat Catchpole ("catch") summarized this dilemma very well:  And the community and Dries, decided almost at the same time to embrace ECMAScript 5, jQuery 2 and drop IE8 support. The change record was modified (to include IE8 as not supported). And we all rejoiced, specially front-end developers. Yay! To end this small story, I will link it to the beginning: there is a task pending about removing HTML5Shiv from Drupal core. All the IE8 issues are spread in drupal.org, so it's nice that nod_ created a meta issue: Drop IE8 support.Present. 2014Looking back, it looks like dropping IE8 support was a good decision. This allowed core developers to write more efficient CSS3 and ECMAScript 5 code. And we avoid to waste the valuable time of core developers supporting old browsers. We jumped on the bandwagon of modern JavaScript libraries.  As I said sometimes, the biggest change in Drupal core front-end is not Twig, it's Drupal core dropping IE8 support. The only big problem is that IE8 is dying very slowly. During the discussions in 2012-2013 we thought that IE8 usage will drop fast (we wanted to believe that). But the reality hurts, This is a chart from StatCounter (IE8 has a 4.71% usage. IE11 is not available in the chart, but it has a 6.29% usage in March 2014):  From netmarketshare.com, the trend is even worse. IE8 has still 21.14% of the browser share on March 2014. 
I hid other browsers in the charts to highlight the situation with Internet Explorer.But one thing is clear: IE8 seems to be more popular than IE9, IE10 and even IE11. This is mainly due of Windows XP users. Why the difference between StatCounter and Netmarketshare?They have different methodologies.  As I understand, netmarketshare manipulates their data to make them more realistic.They are adding a country level weighting, based on how many internet-users the country has, even if their data samples are tiny. So that could distort a bit their data. But the good thing in netmarketshare methodology, is that they count users not traffic. (the same user is only counted once per day, no matter how many page loads she makes). In the other hand StatCounter counts page visits, not users. For example, for StatCounter, an internet-savy teenager  loading hundreds of pages per day in Chrome, counts the same as 100 hundred "grandpas" that are loading once a day their local newspaper in IE8. There is no winner. Both charts are correct, since they represent different things. But the truth is that there is a lot of people outside there using IE8 today. The hopeEveryone hopes that IE8 dies faster, including Microsoft. Two positive notes:
  • Tomorrow, 8th of April, Microsoft is announcing the drop of Windows XP support. No more updates. 
  • IE8 doesn't exist in mobile phones. The trend is that mobile browsers are eating desktop browsers usage, around the world. 
Non official FAQ. Drupal & IE8What if you try to load a Drupal 8 website with IE8? IE8 won't support many CSS3 stuff and EcmaScript 5 code. So a broken layout and lost JavaScript funcionality will be the normal thing to see. Drupal will load jQuery 2.x (that uses addEventListener method), IE8 will complain about it, stop parsing jQuery, and all your jQuery code won't work because "SCRIPT5009: jQuery is undefined". What if a customer asks for IE8 support?Stick to Drupal 7. The other option is to use a Drupal 8 and the work-in-progress-contrib-module IE8 Drupal module, that should downgrade jQuery to 1.x branch and include lots of polyfills to support ECMAScript 5 in IE8. Personally, it sounds to me too "magical",  that it could fix all CSS and broken JS, specially if your site has many contrib modules. But for sure, it will help. Also notice that Drupal helps the situation a bit,  including "X-UA-Compatible" http header to force IE use the most recent IE engine. What if I'm maintainer of Drupal module or theme? Drupal's core decision is pushing "gently" all the contrib modules and themes to follow the same path. When porting your modules, JavaScript code, etc make sure it works well with jQuery 2.x API. If you’re upgrading your Drupal 7 jQuery code from a version older than 1.9, jQuery team recommends to read the jQuery 1.9 Upgrade Guide since there have been a lot of changes, and help yourself using the jQuery Migrate plugin. Once that is migrated to 1.9, it will be compatible with jQuery 2.x, because they should have same API. Corrections welcomePlease, comment in this article, correct me in case I did wrong assumptions and I will update the post with the most up-to-date information.