Using Drupal 7 Real name module with user reference autocomplete

To use the Real name module with the User reference autocomplete field you have to implement hook_form_alter and add the autocomplete path to the user reference field


 * Function mymodule_form_alter()
 * Implements hook_form_alter() 
function mymodule_form_alter(&$form, &$form_state, $form_id) { 

  if($form_id == 'formname_node_form') {
    $form['fieldname'][LANGUAGE_NONE][0]['uid']['#autocomplete_path'] = 'realname/autocomplete';



Redirect Anonymous users to Login Page in Drupal 7

To redirect the anonymous users to the login page we need to implement hook_init() in our own module, inside the init function we add the redirect code


 * Implements hook_init().
function mymodule_init() {

  // Check if user is anonymous
  if (user_is_anonymous()) {
    $redirect = FALSE;

    // Detect whether this request is for cron or site installation or xmlrpc
    // request.
    foreach (array('cron', 'install', 'xmlrpc') as $task) {
      // Generate a path for the task
      $path = base_path() . "{$task}.php";
      // See if we have a match
      if (substr(request_uri(), 0, strlen($path)) == $path) {
        // Stop here

    // Proceed if the request is not coming from the command-line
    if (!drupal_is_cli()) {

        // Determine the current path
        $path = drupal_strtolower(filter_xss($_GET['q']));

        // Convert the path if this is the home page
        $path = $path ? $path : '<front>';

        // Continue only if we're not on the login page
        if ($path != 'user/login') {
         $redirect = TRUE;

        // See if we're going to redirect
        if ($redirect) {
          // See if we have a message to display
          if ($message = variable_get('anonymous_login_message', NULL)) {

          // Redirect to the login, keeping the requested path
          drupal_goto('user/login', array('query' => drupal_get_destination()));

Get all metadata fields for odata service

In order to get all the metadata fields for oData metadata using javascript use the getServiceMetadata()

var oModel = this.getView().getModel();
var metadata = oModel.getServiceMetadata();

//Get the fields
var entityRef = metadata.dataServices.schema[0].entityType[0];
var listOfProperties =;

for (var i = 0; i < listOfProperties.length; i++) {
	var a = listOfProperties[i].name;
	console.log(a); // a is the field name

entityType[0] => change 0 to the index of the service path that you want

Consume SAP ODATA Service using php on linux

Run: yum install php-xml
After that check if PHP CURL and PHP XSL extensions are installed and enabled on the server

copy the content of framework folder to /opt/odataphp (you can choose another path)

in php.ini add the following:
include_path = “/opt/odataphp”

;OData SDK for PHP Library Path
ODataphp_path = “/opt/odataphp”

then restart your httpd: service httpd restart

On linux you will face this error:
Failed opening required ‘Resource\Messages.php’

to fix this go to odataphp/Common/ACSUtil.php and change the ‘\’ to ‘/’ in the require_once statements at the begining
require_once ‘Resource\Messages.php’;
require_once ‘Common\Collection.php’;
. .

make it:
require_once ‘Resource/Messages.php’;
require_once ‘Common/Collection.php’;
. .


Suppose we have the following Odata service path:


To generate the proxy use the following:

php /opt/odataphp/PHPDataSvcUtil.php /uri=http://username:password@URL:8044/sap/opu/odata/sap/MYSERVICE_SRV /out=/home/tassaf/testodata.php

How to replace SAP Fiori Launchpad logo

To change your fiori launchpad logo you have to create your custom theme using the Theme Designer (/UI5/THEME_DESIGNER), there you can upload your own logo and background.


But if you face problems in the image upload then you can replace the logo by uploading your custom image with the same name and replace the original logo in the mime.

to do that:

Go to (SE80 -> MIME Repository) under the path /sap/public/bc/ui5/LIBRARIES/VER/lib_version/


then replace the logo image with your custom one.