Services

  • Drupal CMS Developer
  • Website speed optimisation
  • Drupal 6 to Drupal 8 migrations

Welcome

Welcome, I am a Web Developer based in Madrid, Spain originally from the UK. I studied Computer Science & eBusiness at Loughborough University. I specialise in Content Management System websites

Drupal

Drupal 8 custom entity entity_reference field filtered by role in select box

I have a custom entity, I want to create an entity form, within that entity I have an entity_reference field which references users. I want the field to be a select box, but I don't want to display all users on the Drupal 8 site, instead I only want to show users with a specific role. You can actually do this via the base field definition in the entity, you don't have to create a view like everyone suggests nor override classes, its actually quite easy when you know how...

<?php
$fields['sales_manager_id'] = BaseFieldDefinition::create('entity_reference')

Drupal 6 override theme for a page in a module

This is actually quite simple. Lets say you want to override the admin theme only when creating a new node of type TYPEX

Drupal - completely render another node including hooks

If you need to completely load another node in a module which includes the content element of the node object then use the following code...

<?php
$node
= node_load($nid);
$node->build_mode = 'full node';
$node = node_build_content($node);
drupal_render($node->content);
content_alter($node);
?>

Just replace $nid with your node id that you want to render and your $node is ready to go.

Pasat 4b Payment Method (uc_pasat4b) setup instructions

I was receiving errors from the bank system after having installed the uc_pasat4b module - http://www.ubercart.org/project/uc_pasat4b. After having used the sermepa system for every other website I have built, I was totally confused as to why it wasn't working and why the module wasn't sending all the data that I thought it should be.

Remove "not verified" from comments

Just insert the following code into your template.php in your theme...

<?php
function phptemplate_username($object) {

if ($object->uid && $object->name) {
// Shorten the name when it is too long or it will break many tables.
if (drupal_strlen($object->name) > 20) {
$name = drupal_substr($object->name, 0, 15) .'...';
}
else {
$name = $object->name;
}

if (user_access('access user profiles')) {
$output = l($name, 'user/'. $object->uid, array('title' => t('View user profile.')));
}
else {
$output = check_plain($name);

Using date popup fields from the date module

I found it hard to find information on how to implement a date field in your forms using the form API. I actually wanted a date popup field. Below is the code for using it

$form['dob'] = array(
  '#type' => 'date_popup',
  '#title' => t('DOB'),
  '#date_format' => 'Y-m-d',
  '#date_year_range' => '-100:+0',
);

You can also find more options here http://drupal.org/node/292667

Place a link to a view page next to the node edit link

I was trying place a link to a views page in the tabs that appear on nodes, I wanted it to appear link "Node Edit MyNewLink". The way to do this is to set the page URL "node/%/MyNewView", and create a normal "menu tab". The link will automatically appear, just make sure you replace "MyNewView" in your view path to something relevant.

Display signature in User profile page

I was really surprised that Drupal as standard did not show the user signature on the user profile, it doesn't even give you the option! It's really simple to do if you know how but took me a while to figure out.

You must create a module (see drupal documentation for doing that) and paste the following in...

function MYMODULE-NAME_profile_alter(&$account) {
$account->content['summary']['signature'] = array (
'#type' => user_profile_item,
'#title' => t('About the writer'),
'#value' => $account->signature,
'#weight' => -1,
);
}

Drupal Views2 - Display all values if no results with exposed filter

I had an issue where I had a google map showing the locations of results, and a filter which helped you zoom in on locations. Basically you typed a location and the map showed the location of the results as well as some listings. However, if there were no results, instead of showing an empty page, I wanted the google map to appear with all results and an error message. What I did was set up an "Empty text" value which called a views function "views_embed_view()", I then created a block within that view but without the exposed filter (actually removing that filter all together).

Views 2 - Don't list / Exclude current page

If you want to create any normal listing based on category or content type and say have it appear in a block across several pages, but want to make sure that the page you are currently on doesn't appear in the list, then the below should help
Instructions made from a collection of information found in Drupal website...

1). Open up your view
2). Create an argument of Node > Node id.
3). Then choose the radio button option of "Provide default argument"

Syndicate content