Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough
Jan 08 2021
Jan 08

(Available as freelancer)

Joris Snoek

Business Consultant
/ Drupal Developer

Last week we released 'group chats' in Drupal distribution OpenLucius, a social productivity platform. At first sight it maybe looks like a small module. But it took quite some effort to get to this release. Also because I wanted to release it open source: no concessions in (code) quality and maintainability.

Our 'group chat journey' started around 3 years ago, when we kicked off building OpenLucius on Drupal 8. We thought it was best to implement the realtimeness with MongoDB, because of the no sequel character and its speed. Also, a lot of chat examples were using the MEAN stack.

ReactJS / VueJS (not needed)

Also, javascript frameworks like ReactJS and VueJS were/are a hype -some developers like to jump on it without looking into native Drupal alternatives, I also fell into that trap -it's a dangerous area:

Hello over-engineering, complexity and project misery.

We thought we needed it for frontend interactivity, but that implementation added even more unnecessary complexity to the project.

Drupal 8

After a long struggle, that Drupal 8 version never saw the light of day. We did use it for a while internally but it was not suitable for the outside world -that's a euphemism right there.

Native Drupal 9 group chat, a PoC

So about a year ago I started with a proof of concept to see if realtime group chat was possible with use of just Mysql and jQuery, it turned out it did! So that meant that the group chat module could be implemented native in Drupal.

That was a huge relief and paved the way to an open source release. Because I wanted the installation process to be as simple as possible for everybody, not complex with installing ReactJS / MongoDB and what not.

Just click through the Drupal install wizard and done, that was the goal -and we reached that.

Well.., full disclosure: one piece of external tech required is Node.js (with Socket.io). Else realtime emitting/pushing messages in 'rooms' (group chats) just isn't going to work, Drupal core has no Websocket tech built-in.

But installing the Node.js chat engine also is a few click operation after installing OpenLucius. And: it's optional, so a basic Drupal wizard install is the only thing required to get OpenLucius up and running.

Fast forward 2021, Drupal natives Mysql and jQuery FTW!

So, after the successful proof of concept in 2020, it is safe to say:

be very considered when implementing external tech. Drupal core has excellent native tech for facilitating speed and interactive UI's.

Of course the tech you choose in the end depends on your requirements/user stories. But just make sure you invest enough time in analysing Drupal core and contrib modules, before integrating external tech.

Especially if you want to release open source.

Code for performance

So Drupal natives Mysql and jQuery can work great.. as long as you code it right. And with 'right' I mean, in our case of the group chat, that the code needs to be as lean as possible: chat messages must eventually be realtime.

So I implemented custom Drupal entities and custom code that only does the thing it needs to do, nothing more and certainly nothing less (so for example the Drupal core node system is obviously not handy in this case).

To wrap it up, it turned out that these rules prevailed:

It's hard to make things simple. Experience is the grandmaster of all skills.

Technical details in next blog

In my follow up blog I will get into the tech behind the group chat in Drupal: the use cases and how I implemented them, all without page refresh / Drupal AJAX based:

  • Chat screen initialisation
  • Adding messages and realtime emitting them to all chat users
  • Files uploads via AJAX
  • Dynamic theme libraries, for socket.io connection
  • Node.js / Socket.io implementation
  • @mentions javascript library, with auto suggest
  • Mailing the people that where @mentioned
  • Security and permissions
  • Security hardening with group uuid's
  • How to handle CORS if socket.io runs on external server
  • If connection drops, make sure no messages are missed
  • Edit messages via AJAX
  • Deleting files from the chat via AJAX
  • Dependency injection

    So stay tuned y'all!

Try now or download open source

If you want to test the group chat in OpenLucius this instant, that of course is possible, click here to get started -> Hit 'try now' button. Or download and install OpenLucius yourself via the project page on Drupal.org

Jan 06 2021
Jan 06
Jan 06, 2021 Product

Nowadays every organization needs/has some kind of group chat, like Slack or Microsoft Teams. But those chats are often detached from your other team activity like: project management, social posts, files and folders. Communication, work and documentation gets fragmented easily - very frustrating.

Often, group chat is just another island with a lot of distraction.

It doesn't have to be like that: our brand new and integrated group chats cause none of the above, but they áre:

Integrated with all other teamwork

Integrated in groups, use our group chat together with all your other team activity like:

  • Projects and tasks
  • Messages
  • Stories
  • Notebooks
  • Files and folders
  • Social posts
  • Polls
  • Culture/social questions
  • Check-ins
  • Shout-outs
  • Icebreakers
  • A task board (kanban) that's usable for users of all digital levels

Customizable, brandable

Just like the rest of the Lucius features, our group chat is:

  • Customizable to your organization's needs and workflows
  • ‘Brandable’ to your companies house style
  • Because: 100% open source

And last, but not least:

  • Multilingual
  • Also works easily with clients
  • Extendable with extra needed modules, integrations, functions or permissions
  • OpenSaas
  • Private hosting is possible

Basic features

group chat open source

Test our Group chat now, or install it yourself open source.

If you want to test our group chat this instant, that of course is possible, click underneath to get started. Or download and install OpenLucius open source yourself.

All-in-one toolkit for remote work -and culture.   Try for free now

Download and install OpenLucius open source yourself.   Download and install

Dec 15 2020
Dec 15
Dec 15, 2020 Product

Notebooks are essential for every organization, project or team. They provide a central place for consistent documentation, so we implemented them in the latest update of Lucius

You can think of notebooks as simple text documents. Which facilitate a central, consistent place for all your documentation needed in your organization, department, project or team.

You can also use them for example for:

  • General manuals;
  • Project documentation;
  • Team information;
  • Onboarding information for new people.

Just like stories, current version is a starting point for Notebooks. Further features will be done based on user feedback. But it’s enough to work with in our experience testing them.

Customizable, brandable

Just like the rest of the Lucius features, Notebooks are:

  • Customizable to your organization's needs;
  • ‘Brandable’ to your companies house style;
  • Because: 100% open source :)

Test Notebooks this instant, or install Lucius yourself

If you want to test Notebooks this instant, that of course is possible: try them now for free. Or download and install OpenLucius yourself via the project page on Drupal.org

Jul 14 2020
Jul 14
Jul 14, 2020 Drupal

During the development of Lucius we built quite a lot of features, that are embedded in the product (an open source Drupal distribution). But we figured some of these might come in handy for other Drupal site owners, outside of the OpenLucius Drupal install profile.

So this is the first release we did: "Simple Like Button", a very simple like button Drupal module that works in two steps:

  1. Install module
  2. Place block
  3. Done!

Features

  • Instant feedback for end-user: count likes +1 or -1;
  • Adds names of users that liked the content;
  • It's compatible with all (custom) entities and bundles;
  • Compatible with all 'authenticated' roles, not with 'anonymous';
  • (non feature) Not compatible with Views at the moment.

Built with custom Drupal AJAX form

It's built with a custom AJAX Form, so we don't have to worry about building a custom AJAX route, a CSRF token and custom Javascripts to handle the user interactions.

While CSRF access checking looks like it can be easily integrated via module_name.routes.yml, ajax form was still more easy to implement.

Downside is that all forms can be cached, in high content site can lead up to unnecessary caching data.

And if you disagree on this approach, please let me know in the comments.

So anyway, if you are looking for a compact example of implementing an AJAX Form, check out the code of this module or the example in this blog.

Built with a Drupal custom entity

We used a Drupal entity for easy management of data:

  • Defining the data model and database table, easy installable.
  • CRUD: the Create, Read, Update and Delete queries are more easy if you work with Drupal entities.

So if you are looking for a compact example of implementing a custom entity, check out the code of this module.

And if you disagree on using a custom Drupal entity here, please let me know in the comments below.

Download the module

Check it out on Drupal.org. Go to download page

Jun 26 2020
Jun 26
Jun 26, 2020 Drupal

For our Drupal distribution we needed to redirect all anonymous users to the login page, as for now it's implemented as a closed platform for social collaboration. The Drupal 8 way didn't work anymore; we fixed it for Drupal 9 and published a working module.

So if you're building a Drupal social intranet, collaboration tool or community this might help you to direct them the right way -so they don't get an unfriendly 'access denied'.

Keep in mind that you still have to build the correct access control into all your pages with help of permissions / access checks / advanced route access, this module doesn't provide for that.

All-in-one Drupal based toolkit for remote work. Check how Lucius works

Clone and run off

We published the Drupal module here on Github so you can copy it and run off with it to do whatever you need. At the moment it's not a published Drupal.org project with all kinds of configurable stuff.

A short explanation of the code

First you'll have to implement an 'Event Subscriber' in the .services.yml file.

drupal event subscriber

More info: Subscribe to and dispatch events.

Next, it took a while before we figured it out, but this code in /src/EventSubscriber/AnonymousRedirectSubscriber.php is all it takes to make it work:

Drupal anonymous redirect subscriber

  1. More info on responding to events in Drupal here on Drupalize.me.
  2. Get current user and facilitate 'account' (this is not dependency injection, see comments).
  3. Get current request with ->getRequest(), here's what differs from the Drupal 8 version: we couldn't get ->getRouteName() to work properly.
  4. Check if current user is anonymous, but exclude some paths. Also, we had to facilitate user/reset/* with php's fnmatch, because that path contains a variable (the reset hash).
  5. Respond with the redirect to Drupal's login page.

Drupal 8 version

You can find the previous Drupal 8 code here, and we also found the Anonymous login module, but both didn't work in our Drupal 9 (then beta) install.

'quick-start' Drupal to test

To test this module fast in a fresh install, Drupal's quick-start might come in handy.

Need this as a contrib Drupal module?

Please let me know in comments down below, if there is enough positive feedback on this we might make it configurable and contrib it!

Jun 19 2019
Jun 19

(Available as freelancer)

Joris Snoek

Business Consultant
/ Drupal Developer

Last month we worked in a project where we implemented a progressively decoupled Drupal platform. We needed a React.js frontend to to all kind of magic that was less available in Twig. Also, this way frontend engineers and backend engineers could work more loosely together, which is great.

Main reason we choose progressive decoupled instead of fully decoupled is because we wanted to make use of Drupal's roles, permissions and authentication, plus some other Drupal native stuff that in fully headless would become very cumbersome to deal with.

Check out this blog on 'How to decouple Drupal in 2019' and find out if you also need Drupal beheading or not.

React libraries dynamically in Drupal

The target was to implement the React.js libraries in Drupal pages, so React would load withín Drupal and we could use all native Drupal goodies like authentication.

By the way: you can also use Drupal authentication when fully decoupled, check this article

So, the thing with React is: every time you release a new version of your App, you'll have to render a new build, that sort of looks like this:

More specifically, the .js and .css files we need to load in Drupal are defined in asset-manifest.json:

So, those files need to be loaded in Drupal, and change every time you run a new build in your React App for example with npm run build.

But you can't add these React javascript libraries to your theme's YOURTHEME.libraries.yml because with the next build the links be be different.

hook_library_info_build() to the rescue

Aaaah, so Drupal 8 provides us with hook_library_info_build() that will save our day (づ。◕‿‿◕。)づ

Now, how we did this:

Implement the Drupal hook in your .module file (For highlighting's sake, I added .php, loose that. #nobrainer):

As you see, it will read React's asset-manifest.json and registers all .js and .css files of React.js as a library in Drupal.

Next up, you can render this library for example in a Controller like this:

Wrap up

So that's how we integrated React.js within Drupal pages and combined the power of a React frontend with the power of Drupal goodies, in a 'progressively decoupled' way.

Please let me know if you have any questions.

Feb 10 2016
Feb 10

(Available as freelancer)

Joris Snoek

Business Consultant
/ Drupal Developer

Search engine optimization (SEO) has always been important, but in recent years its importance seems to have increased significantly. We were more often dealing with Drupal SEO implementations than in previous years. Many of the implementations contained overlapping components. Below we will discuss the most important ones:

1. Speed

Google Page Speed is a good indicator of how speed is experienced by end users and therefore by Google. Google attaches great importance to speed because end users are simply doing the same.

An example of a test of the front page of this site:

As you can see we can further optimize mobile and desktop by following the instructions provided. Although on our Dutch blog we have a Node.js frontend (and a headless Drupal 8 backend) a Drupal frontend can be tested as well with the Google Page Speed tool. The tool is testing, among others, the following:

  • JS and CSS aggregation and minimize (minify)
  • GZIP / browser caching
  • Optimized images
  • Landing page redirects
  • Prioritize visible content
  • User experience issues, for example the use of non generic plug-ins.

2. Schema.org

Schema.org is a collaboration between Google, Yahoo! and Bing to standardize the way data is structured in web pages. By using these standards these search engines are ‘snapping’ the content of your web page better, resulting in a significant SEO boost.

The schema.org library contains descriptive tags for content like films, persons, organizations, events, locations, etc. The purpose of the search engine is to make search results more clear, allowing people to easily find the right web pages.

3. Mobile compatible / responsiveness

2015 brought us mobilegeddon: if your website is not mobile ready then Google will appoint you penalties resulting in a lower ranking. And rightly so, a large part of the website visitors are using internet on their mobiles; and you would like to give them a good experience. You can test here if your website is mobile compatible.

4. Google Webmaster Tools / Search console

Essential SEO tool, sign in here and register your website. Then it is important to upload a XML sitemap. The Drupal module XML sitemap will help you with this. Once you have done that, you will be able to see how your website is ranking in the organic results of Google:

  • Which keywords enable your pages to be found in the search results.
  • What are people really clicking so that they land on your website.
  • Errors on your website.
  • Links that are not correct.
  • Links that are not accessible.
  • Schema.org implementation: how is Google treating the enriched html pages.

See below for example the dashboard of this website, with links unfolded and all the insights you can find here:

5. Write good, long content

Apparently Google is rating your Drupal website higher when you are publishing long and good quality content. Long and good pieces of content are also adding to the acquisition of new clients:

  • You have something valuable to promote on social media.
  • You have an excuse to reach out to your potential customers.
  • Visitors are staying longer on your website.
  • You are creating authority.

Read here more details about the how and why.

Areas of importance when writing content

  • Backlinks, make sure you get links on other websites that are highly rated.
  • Limit the number of relevant internal and external links, so that Google (and the - visitor) can better understand the context of your article.
  • Analyze the (successful) competitors: discover where they are, what they link and how they dominate social media.
  • Make sure your blog website is coherent, not a website with islands where non-cohesive content is separated from one another.
  • Update regularly: check for example once every month your articles and improve where appropriate: cohesiveness, spelling mistakes, new insights, etc.
  • Allow visitors to place comments using Disquss that has become a social media platform where you can attract inbound links.

Useful Drupal SEO modules

6. Page title

By default Drupal has one field to enter the title of an article. This title is used for both the page title as the ‘html title’:

The html title is important for SEO; usually you would like to define it differently than the readable title of the article (as the visitor is viewing it). This module is solving this problem and allows you to manage two titles individually.

You can also give the HTML title a particular predefined format so that it is created depending on the content type. For example “Blog Lucius | 18 Drupal SEO modules and tools for better findability in Google”. Where ‘Blog Lucius’ is always automatically stated in the beginning of the title with a pipe (‘|’) in between.

Download and more info on Page Title - (Drupal 7 - Drupal 8 info)

7. Metatags

Years ago meta keywords were one of the most important elements used to be found. But not anymore, Google is finding your Drupal site mainly with content and links to your pages. The meta keywords are still important but mainly for:

Indicating snippets
The (summary) text about your page that will appear in the search engine:

Open Graph implementation
Rapidly emerging technology, important for previewing your page on social media and now also in for example Gmail:

Download and more info on Metatag - (Drupal 7 & Drupal 8)

8. Pathauto & Subpathauto

Pathauto is a widely used Drupal module: it converts standard Drupal (/node/123) links to readable links (/news/this-is-a-news-item). Useful for your visitors and thus for Google.

Download and more info on Pathauto - (Drupal 7 & Drupal 8 dev)

Subpathauto is an extension of Pathauto: it recognizes sub-paths and automatically generates associated paths.

Download and more info on Sub-Pathauto - (Drupal 7)

9. Pathauto persistent state

The popular Drupal module Pathauto is useful for automatically creating nice URL’s. It is also possible to exclude particular content from an ‘automatic alias’ and then manually enter the URL.

Pathauto sometimes ‘forgets’ that the URL of certain articles was manually set, and creates them again automatically. As a result the URL of your page could change without you realizing it, not handy..

This Drupal module is solving this problem: it makes sure that Pathauto remembers for which articles you have turned off ‘automatic alias’.

Download and more info on Pathauto persistent state

10. Global redirect

Avoid duplicate content. Ensures for example that 'node/123' is no longer available, but only the search engine friendly URL. It also checks if clean URL’s are enabled and checks whether visitors have access before performing a redirect.

Download and more info on Global Redirect - (Drupal 7 - Drupal 8)

11. Redirect

It can happen that the title of an article needs to be changed, usually the URL is changing then as well. This module creates a 301 - Permanent redirect so that the users from an old URL are automatically redirected to the new path. This way Google also knows that the new URL needs to be indexed and that the old one can be removed.

Download and more info on Redirect - (Drupal 7 - Drupal 8 info)

12. XML sitemap

Necessary for an insight into your Drupal pages in Google's Search console, see ‘Google Webmaster Tools / Search console’ above for more information.

Download and more info on XML sitemap (Drupal 7, Drupal 8 info).

13. HTML Purifier

Can clean the HTML of content so that it continues to comply with the W3C standards.

Download and more info on HTML Purifier - (Drupal 7, Drupal 8 info ).

14. Search 404

A standard 404 page (‘page not found’) is providing rather brief information for your visitor. This popular module is changing this: it does not show a static page, but will search in your Drupal system and will show visitors results of pages they might have been searching for.
This feature will also have a positive influence on the SEO of your Drupal system.

Download and more info on Search 404 (Drupal 7 & Drupal 8)

15. Site verify

Useful mini module to verify your site in Google’s webmaster tools.

Download and more info on Site verify - (Drupal 7, Drupal 8 info).

16. Link checker

Analyse your content and detect dead links, important to fix them for your visitors and thus for Google.

Download and more info on Link checker - (Drupal 7, Drupal 8 info).

17. Taxonomy Title

Similar to the previously mentioned ‘Page title’, using this module you can among others change the (html) page title per term / tag.

Download and more info on Taxonomy Title - (Drupal 7)

18. Menu attributes

Add html elements to menu links: id, name, class, style and rel. This allows you to add among others ‘rel=nofollow’ to design the flow of links in your website better.

Download and more info on Menu attributes - (Drupal 7, Drupal 8 info).

Wrap up

Ok, enough SEO for now, hopefully you are not immediately conquering our ranking in Google ;-) Questions or feedback let me know in the comments or via @joris_lucius.

Jan 23 2015
Jan 23

(Available as freelancer)

Joris Snoek

Business Consultant
/ Drupal Developer

So, here at Lucius HQ we are planning on building a RESTful API (web services) on top on Drupal distribution OpenLucius.

We want to do this so all 3rd party programmers, thus 3rd party applications, can integrate with OpenLucius. And not only Drupal developers and Drupal modules. 

For example: integrate time tracking with Toggle, invoicing with Freshbooks or integrating with other case trackers like Jira, Asana or Basecamp. And there are a lot more apps out there with huge potential you can tap into.

So, a brief intro in web services in Drupal:

What is a web service API

W3C defines a web service as follows:

‘A Web service is a software system designed to support interoperable machine-to-machine interaction over a network’.

In other words: web services is a documented and defined way for two computers to communicate with each other over the internet. A computer can be anything connected to the internet. So even a Playstation, a smart watch or a thermostat. Think of: 'the internet of things'.

Application Programmer Interface

API means: Application Programmer Interface. API’s define how software and thus computers can communicate with each other. We are constantly using API’s without noticing it. For example, when you attach your laptop to an external monitor. This is done by means of an API. The programs are 'communicating' with each other without any human intervention.

Standardized and documented

An API can also be seen as a standardized and documented way to get access to content and functionality of an application. For example, as an independent developer you can get access to data from Facebook using the Facebook API. An example of Facebook’s ‘Graph API explorer’ that everyone can use:

API documentation

API Documentation is very important, otherwise nobody will know how to use the API to obtain the correct information. An API is worthless without proper documentation.

How does it basically work

An external application makes a request for data through a Drupal web service API. Drupal passes data back in the appropriate structured way (e.g. JSON), so that the external application can use the data. The external program can also create users, create a node, reset a password, etc.

Why web services

In most cases web services are used to provide mobile applications with data. When you look for example at the App nu.nl, then these news items will have to be managed somewhere. These same news items are posted on their website, but also on Android apps and in future maybe on smart TV’s, smart watches and anything else yet to be invented.

Future proof

Web services are future oriented: whatever will come after iOS or Android, the new application platform will also be able to retrieve and modify data via the desired web service API.

In other words: the internet of things can be centrally provided with content, users, etc.

Web services in Drupal

There are several modules in Drupal that can facilitate web services, the most famous are Restws and Services.

These two modules ensure that data and internal functions are openly served to other applications through a Drupal web services API. An external application can 'communicate with these modules' and receive structured data that can be used. Examples of external applications: an iOS or Android app, but also a Playstation, smart TV, smart watch or even a thermostat. In other words, all things in the internet of things.

Drupal Module: Restws

Restws is great in RESTful web services and the necessary CRUD action for all Drupal entities, but has no additional web services like SOAP, XML-RPC, etc. It is also not possible to define and configure ‘service endpoints’.

Drupal Module: Services

The Services module can do everything that Restws can do and more. It is a complete toolkit to provide Drupal with web services. It knows Drupal’s node, entity en CRUD system and provides opportunities to create and configure service endpoints yourself. The module also supports multiple interfaces like REST, XMLRPC, JSON, JSON-RPC, SOAP, AMF and more.

It also provides a number of standard features, allowing you to quickly have the standard web services up and running, for example requesting node content details. This can be done within 10 minutes. Specific use cases are obviously requiring more effort, but with all custom needs this Service module is facilitating a large part of the required functions. Such as creating users, creating a node, reset a password, etc.

Drupal Module: Views data sources

This is a module that lets you create endpoints through Views and serve data through that endpoint. And all this without having to code a line. Relevant data can be configured in the View. Note that this is still an alpha version and can be handy for standard lists: for example the last 10 news items.

More complex use cases

But when the query becomes more complex this module is not working satisfactory yet. You will then have to create a custom endpoint in code and code your own queries. But these custom endpoints do let you hook into the Services module, which is facilitating many functions. So there is no need to code a Drupal web service from scratch.

Web services in Drupal 8

Drupal 8 incorporates web services in the Drupal core, so modules will not be needed anymore!

Wrap up

Ok, that's it for now. But since we are currently working enthusiastically on a major Drupal web services project, blogs will follow with specific use cases about this.

-- Cheers!

Sources

Source header image

This video is a very good resource, thanks Mkorostoff

Ow yeah.., and don't foget to check out other Youtube videos on Drupal web services

Sep 08 2014
Sep 08

(Available as freelancer)

Joris Snoek

Business Consultant
/ Drupal Developer

Geen introductie vandaag, let's go! :)

11) Security Review


Bron afbeelding

Voorzorg en veiligheid boven alles, dit zou hoge prio moeten hebben bij elk project. Deze module kan je daar aardig snel mee helpen.

Je kunt hiermee namelijk een checklist genereren die nagaat of alle voor de hand liggende Drupal veiligheidsfouten zijn nagelopen/ge-checkt.

Hij checkt bijvoorbeeld:

  • Is je Drupal bestandsysteem juist ingesteld?
  • Wordt er geen gevaarlijk content toegelaten (tegen bv cross site scripting / XSS)?
  • Of er op een veilige manier fouten worden gerapporteerd?
  • Zijn je 'Drupal private files' wel echt privé?
  • Beveiliging tegen 'brute force attacks' (vele malen achter elkaar kunnen inloggen om wachtwoord te raden)
  • ...en meer (nu ben ik het zat :-) ).

https://www.drupal.org/project/security_review

10) Dynamic Internal Linking

Bron afbeelding

Module die de SEO van je Drupal website kan boosten. We doen het zelf ook te weinig, maar door interne links schijnt het dat zoekmachines je website beter kunnen lezen / structureren. Dus vinden zoekmachine dat leuk en daardoor boost je je SEO.

Deze module kan door jou voorgedefiniëerde woorden automatisch intern laten linken.

https://www.drupal.org/project/dynamic_internal_linking

09) Entity Lister (Drupal Developer module)

Als die hard Drupal developer zal je relatief vaak gebruik maken van de 'EntityFieldQuery' functie. Hierin zag de bouwer van deze module veel herhaaldelijk werk bij verschillende implementaties. En zoals een goede developer betaamt, wordt eenzelfde functie nooit twee maal geschreven.

Deze Drupal API module zorgt er dus voor dat je niet elke keer hetzelfde 'EntityFieldQuery proces' hoeft te coderen. Doorgaans vormen deze stappen dat proces:

  • 1) Entity ID's querien mbt EntityFieldQuery
  • 2) Entity laden m.b.v. entity_load()
  • 3) Elke entity door een view functie (bv node_view() of entity_view() heen halen.
  • 4) Elke entity 'redenderen' m.b.v. drupal_render()

Deze module implementeert een class waarin dit allemaal wordt gefaciliteerd voor je. Het is een 100% Drupal API / Developer module, wat wil zeggen dat er geen grafische interface is maar middels Drupal code functies benut kunnen worden.

Hij heeft een aantal handige tools aan boord:

  • Bepaal hoeveelheid items, bundles, 'view mode', sortering, paginanummering, caching, tabel headers en meer.
  • Je kunt meerdere 'bundles' combineren in een lijst
  • Caching is goed voorbereid, super belangrijk voor performance van je Drupal systeem.
  • AJAX technieken mogelijk
  • Integratie voor 'node view permissies'
  • Ingebouwde 'access control' voor Drupal nodes, gebruikers en reacties.

Je kan het bijna zien als een 'Drupal Views voor developers' :-)

https://www.drupal.org/project/entity_lister

08) Inline registration

Maakt de drempel lager voor mensen om zich te registreren op je Drupal website.

Deze module integreert namelijk het registratieformulier met het 'toevoegen van content formulier'. Waardoor het slechts 1 stap kost voor mensen om content toe te voegen in plaats van 2 stappen.

https://www.drupal.org/project/inline_registration

07) Memory profiler (Drupal Developer module)

Wanneer je Drupal website performance problemen krijgt, kan dit veroorzaakt worden doordat het geheugen van je server te snel vol loopt. Een oorzaak hiervan is meestal niet-geoptimaliseerde code of queries.

Deze lichtgewicht module helpt je bij het zoeken naar pagina's binnen je Drupal site die veel geheugen vreten.

Met behulp van de DrupalDevel module kan je door pagina's klikken en onder aan je website tevens geheugen statistieken zien. Maar deze module logt alles voor je, zodat je achteraf dit log kan analyseren. Handig joh!

Memcache, bij ons geïnstalleerd op alle Drupal systemen, wordt ook ondersteunt sinds kort.

https://www.drupal.org/project/memory_profiler

06) Picture

Bron afbeelding

Dit is een backport van de Drupal 8 'Picture' module.

Deze module kan voor een performance optimalisatie zorgen: hij zorgt ervoor dat een alternatief afbeelding (vooral qua MB's) wordt uit geserveerd, wanneer blijkt dat er weinig bandbreedte is, of wanneer blijkt dat het scherm geen hoog resolutie afbeelding (niet-retina) nodig heeft.

https://www.drupal.org/project/picture

05) Restrict Login or Role Access by IP Address

Drupal veiligheid, wie is er niet groot mee geworden :-)

Deze module biedt extra functies tbv de veiligheid van je Drupal website. Hij kan ervoor zorgen dat bepaalde gebruikers, of gebruikers met een bepaalde role alleen kunnen inloggen vanaf een bepaalde 'gewhitelist' IP-adres

https://www.drupal.org/project/restrict_by_ip

04) Shared Email

Er zijn van die uitzonderlijke situaties waarin je graag wilt dat je meerdere Drupal users kan aanmaken, met hetzelfde e-mail adres.
Bij ons kan dit voornamelijk bij ontwikkel -en testdoeleinden handig zijn.

Deze module doet hierin zijn ding.

https://www.drupal.org/project/sharedemail

03) Node Expire

Soms zou je automatisch, na een bepaalde tijd, een bepaalde handeling op een node willen uitvoeren.

Bijvoorbeeld: depubliceer deze drupal node over twee weken automatisch.

Deze module kan je daarin helpen: je kunt acties uitzetten op nodes die na een bepaalde tijd automatisch worden uitgevoerd.

https://www.drupal.org/project/node_expire

02) Webform steps

Wanneer je webformulier veel velden bevat, is het goed om deze op te delen in stappen.

Je raadt het al: deze module kan dit voor je uitvoeren. En geeft daarom een behoorlijk usability boost, wat het voor je Drupal bezoekers makkelijker maakt om zichzelf te registreren en jij meer conversies behaalt. Iedereen happy!

https://www.drupal.org/project/webform_steps

01) File lock

Sommige geüploade files wil je beschermen, zodat ze niet per ongeluk verwijderd of gewijzigd kunnen worden.

Wanneer je deze module installeert kan je Drupal files 'locken' en weer 'unlocken', zodat ze niet door iemand anders weg gehaald kunnen worden.

https://www.drupal.org/project/file_lock

Wrap up

That's it, vragen of suggesties? Let me know yo!

Aug 28 2014
Aug 28

(Available as freelancer)

Joris Snoek

Business Consultant
/ Drupal Developer

Tijdens controle door de Drupal community van onze Drupal distributie OpenLucius (een Drupal social intranet) liepen we tegen volgende issue aan:

We gebruikte de functie arg(); hier en daar om logica af te vangen. En wat blijkt: "arg() is evil". Dit hadden we kunnen weten, het lijmt argumenten en functies té absoluut aan elkaar vast.

Bericht in een Groep

Een case waar we arg(); gebruikte was: om te bepalen in welke Groep een item toegevoegd wordt. Bijvoorbeeld een Bericht 'Welkom in deze projectgroep' toevoegen in een Groep 'Project nieuwe website'.

*Warning: nerd alarm vanaf hier* :)

Hoe we dit technisch oploste (the evil way)

  • Voeg de group node id toe aan de link om een bericht toe te voegen. Dat werd dus bijvoorbeeld 'node/add/ol-message/34'.
  • We vingen in hook_form_alter() dat argument op met evil arg(); .
  • En zorgde middels code in die hook_form_alter() dat het Bericht middels een Node reference field automatisch werd gekoppeld aan de juiste Groep.

Dat is dus níet goed.

Ok, maar hoe dan?

Collega Thomas heeft hiervoor een oplossing bedacht. Deze is nog wel in alpha fase, we moeten hem dus wel goed testen én de Drupal community moet het met ons eens zijn.

In de basis draait die om het overriden van het standaard Drupal node/add formulier, zodat we het gerefereerde Group node id tot onze beschikking hebben in het formulier. Waarna het ingevoerde Bericht automatisch kan koppelen aan de Groep waar hij toegevoegd wordt.

  1. Voeg een custom hook_menu() toe met een custom callback.
  2. Voeg de custom callback functie toe.
  3. Override het standaard Drupal node/add formulier.
  4. Koppel automatisch, middels code, de Group nid in het node reference field 'Group reference' , zodat het Bericht gekoppeld wordt aan de juiste Groep.

1. Voeg een custom hook_menu() toe

/** * Implements hook_menu() */function openluciuscore_menu() {  $items = array();  $items['node/add/ol-message/%'] = array(    'title'            => t('Message'),    'title callback'   => 'check_plain',    'page callback'    => 'openluciuscore_node_add',    'page arguments'   => array('ol_message', 3),    'access callback'  => 'node_access',    'access arguments' => array(      'create',      'ol_message'    ),    'description'      => t('Facilitates OpenLucius Messages in Groups'),    'type'             => MENU_NORMAL_ITEM  );}
  • Roept de functie 'openluciuscore_node_add' aan
  • En geeft het derde argument uit de URL dynamisch door aan die functie: 'array('ol_message', 3)'

2. De custom callback functie

/** * Custom callback for node add * @param $type * @param $group * @return array */function openluciuscore_node_add($type, $group) {  global $user;  // sanitise group input  $sanatized_group = filter_xss($group);  // check if the user may add content into this group  if (_olcore_user_in_group($sanatized_group, $user -> uid)) {    // load requirements    module_load_include('inc', 'node', 'node.pages');    // fetch form    $form = openluciuscore_node_add_with_group($type, $sanatized_group);  }  return $form;}
  • Vangt de 'Groep variabele' op in het tweede argument van de functie
  • Laadt alle noodzakelijke code uit de core
  • Laad en returnt het 'node/add' formulier

3. Override het standaard Drupal node/add formulier

/** * Custom version of node_add found in the node.pages.inc * @param $type * @param $group * @return array */function openluciuscore_node_add_with_group($type, $group) {  global $user;  $types = node_type_get_types();  $node = (object) array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => LANGUAGE_NONE);  drupal_set_title(t('Create @name', array('@name' => $types[$type]->name)), PASS_THROUGH);  $output = drupal_get_form($type . '_node_form', $node, $group);  return $output;}
  • Laat het standaard Drupal 'node/add' formulier en voegt de extra build info toe om de Groep variabele door te geven.

Wrap up

OK, that's all folks. Vragen of suggesties? Let me know.

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web