Create Empty User as Admin, and force entering info on login For my website, user accounts should only be created by the admin. However, the only fields that should be given by the admin are his full name. All other fields should be supplied by the user himself. For this, I have 2 things I would like to do:

1: Allow the admin to create a new user without supplying required fields.

2: Redirect the user to their profile edit page as long as there are required fields that have not been given.

For 2, I imagine it should be possible with the rules module, although I have not yet tried this. But is there a way to do 1? One thing I have considered is to add a custom page with a simple form to create the user, and to have custom PHP code that will actually create the user. However, I am hoping this is possible without resorting to that.

Edit: The only information I do have are an email, username and full name. All other fields, such as address, profile picture, etc. should be provided by the user themselves.

It's not possible to create a new user without email, username and password.

The only workaround for this is to create placeholders. E.g. always enter username@example.com in the email field where username is the machine name of the user's full name.

As for creating the user without entering the required fields I think it's best to create a custom form. This form would only contain a textfield Full name.

On submit you dynamically generate the username, email and password (see drupal_clean_css_identifier to easily generate a machine name) and create the user object.

Here's a code example:

$full_name = $form_state['values']['full_name'];
$username = drupal_clean_css_identifier($full_name);
$email = $username . '@example.com';

//This will generate a random password, you could set your own here
$password = user_password(8);

//set up the user fields
$fields = array(
  'name' => $username,
  'mail' => $email,
  'pass' => $password,
  'status' => 1,
  'init' => 'email address',
  'roles' => array(
    DRUPAL_AUTHENTICATED_RID => 'authenticated user',
  ),
  // If you have custom field 'Full name' do this:
  'field_full_name' => array(
    LANGUAGE_NONE => array(
      0 => array(
        'value' => $full_name,
      ),
    ),
  ),
);

//the first parameter is left blank so a new user is created
$account = user_save('', $fields);


Why does Drupal say I need to upgrade to 8.0.0 beta 6 when I'm already checked out on that tag? I followed the git instructions at: https://www.drupal.org/project/drupal/git-instructions to get Drupal 8 :

git clone --branch 8.0.x http://git.drupal.org/project/drupal.git .

I then checked out the tag for 8.0.0 beta 6:

git checkout tags/8.0.0-beta6

And this command confirms I'm on that tag:

$ git name-rev --tags --name-only $(git rev-parse HEAD)
8.0.0-beta6

I then prepared for the install: set up a blank database and user and then used this drush command to do the install:

drush site-install standard --account-name=admin --account-pass=admin --db-url=mysql://d8:d8@localhost/d8

When I go into the admin -  admin/reports/status - I'm told that I'm using 8.0.0-dev and that Unknown release date (version 8.0.0-beta6 available) is available.

But why? when I was already on 8.0.0-beta6 branch before I ran the install.

update.module doesn't know about git.

It only understands .info(.yml in D8) files. And .info.yml files only get their version as part of the package building process. If you look at your system.info.yml, it doesn't say anywhere that it is beta6.

There is a module called git deploy, that is trying to fill that gap and extracts version information from git and tells update.module about it, there is a Drupal 8 release but I don't know if it works with the current version.


Is it possible to remove the contextual link for deleting a node? In Drupal 7, can I somehow remove the "delete"-link from the contextual menu?

Some users don't realize that this actually deletes the node. They think it only removes it from the current page but still exists in the database.

You can implement hook_menu_contextual_links_alter() to remove the "delete" link from the contextual links.

function YOURMODULE_menu_contextual_links_alter(&$links, $router_item, $root_path){
  unset($links['node-delete']);
}

However, if your users are irresponsible enough to believe that "deleting" a node does not actually delete it, you may be better off simply removing those users' permissions to delete nodes at all.


Complicated 'double' contextual and relationships view I would like some help on how to implement the following view:
A block that shows all the 'events' happening at any 'location' created by a user.

I have 'event' and 'location' content types. There is a field in the 'event' node which refers to a 'location' node (it's nid).

I am familiar with views, just not sure how to get the 'double filtering' required to show only events that have a location that is created by the user logged in. I cannot create an 'author' relationship to a contextual filter for the location or event to a simple filter, as the view displays events, not locations... Any ideas?

I would create a View of the Content Type Location (these are the nodes created by your users, right?).

Create a Relationship to Author.
Create a Filter to user: current and select Yes in Is the logged in user (NB: this a a regular filter, not a Contextual Filter)
Create a Relationship to the Event type through its reference field to Location (NB: select Entity Reference: Referencing Entity . If you select "Require this relationship" the View will limit the Location types to only those referenced in an Event node
Add any field to the View, but be sure to select the relationship you created in 3 above to show field from the Event type

That's it! Nice question!


How to get hal_json format as Drupal output? I installed Drupal 8 and these modules on my host:

HAL
HTTP Basic Authentication
RESTful Web Services
REST UI
Serialization

These are all core modules except REST UI.

According to Drupal tutorials (https://www.youtube.com/watch?v=4xCndQQVJsg and https://www.youtube.com/watch?v=DnZo5lMICKc) when I enter this URL, Drupal would show JSON format of node 1:

www.example.com/node/1?format=hal_json

But it shows the normal (HTML) view of node 1.

What should I do to get JSON or hal+json format as output?

Send a GET to http://theurl.com/node/1?_format=hal+json

This should work! Make sure you enabled the Resources to read out nodes.


what permissions are needed to give a role ability to access: admin/content list page what permission do i need to give a role to give them access to the list page of content. path: admin/content

This is for drupal 7.

found it! its under this:

Access the content overview page
Get an overview of all content.


Search api solr create a custom search link I try to create a custom search link like this :

l(t('See our Job Ads'), 'search', array('query' => array('f[0]' => 'is_recruiter_nid:' . $nid )));

when i click on the link nothing get filtered.
P.S : i have added the filter 'is_recruiter_nid' in code using the hook_search_api_solr_documents_alter() Something like:

function MYMODULE_search_api_solr_documents_alter(array &$documents, SearchApiIndex $index, array $items) {
  foreach ($documents as $document) {
     ...
     $document->setField('is_recruiter_nid', $recruiter->nid);
  }
}

How I can do this? Is there any example ?

Thanks for your help.

f[0] param doesn't work directly. To allow ApacheSolr to filter results based on custom fields you will need to define them as facet (checkout FacetAPI module) or you can implement hook_apachesolr_query_alter and add your own filters in it.


Assign textfield to each checked option in a checkboxes field Lets say I have a checkboxes field and when I check one of the options, I would like a textfield to appear so I can assign a number (quantity) to it. Every option I check would have its own textfield.

For example, I have a "Fruits" field and I want to be able to say how many of each fruit I have. So it would be something like that:

[x] Apple (3)
[] Grape
[x] Orange (2)

Is there any module that does something similar to that?

Edit:

Another thing that would do the work for me would be a select list of numbers for each option. So by default the options are like that:

[0] Apple
[0] Grape
[0] Orange

So I can simply change the number of fruits in each option by selecting in the dropdown.

The conditional fields module should be suitable for this

  Conditional Fields allows you to manage sets of dependencies between
  fields. When a field is “dependent”, it will only be available for
  editing and displayed if the state of the “dependee” field matches the
  right condition.


Can I use Apache 2.2.15 with mod_rewrite enabled? I currently am running Centos 6 which only comes with Apache 2.2.15.  Yeah, I know it is about time for me to upgrade...  I get the following warning:

  The minimum version of Apache needed to run Drupal without mod_rewrite
  enabled is 2.2.16. See the enabling clean URLs page for more
  information on mod_rewrite.

I have mod_rewrite enabled. Am I okay as is? I don't care about pretty URLs at the moment as I am just learning about Drupal, and will upgrade my OS someday soon.

Yes, you can go with Apache 2.2.15 as long as you have mod_rewrite enabled (so you'll have pretty urls).

From Drupal issue Regression fix: allow Drupal 8 to work without Apache mod_rewrite

  Apache 2.2.16 is only required if mod_rewrite is NOT enabled


File Repository Module Is there anybody have ever used a  moudle that like File Repository ? Who can tell me whether have the similar module in Drupal.org ?

This module should provide these following functions :

(1) Authorised user can create folder and sub folder, upload files into a folder.

(2) Role-based access control:
      a) Authorised user can config the attributes of folder, can assign which role can access this folder.
      b)Folder & sub folder both can set different access control attributes.

Checkout filedepot module.

  The filedepot module is full featured Document Management module that
  has a google docs like feel. It fulfills the need for an integrated
  file management module supporting role and user based security.
  Documents can be saved outside the Drupal public directory to protect
  documents for safe access and distribution.


Create a menu block based on path using views I'm trying to use views 3 to create a view that I can place in a block that is based on the url path

For example

example.com/student/
example.com/student/page1
example.com/student/page2
example.com/student/page3

All 4 pages are in the menu along with other pages
Students
   page1
   page2
   page3

I want to create a view that will display (dynamically) on pages with the following url pattern example.com/student/*
I want the view to only return child menu items that have Student as a parent.

I'm working with menu view, but I can not get the contextual filter and relationship to work correctly.  Any tips. Or an alternate way to accomplish

You can simply use Menu Block module to accomplish this task. If you want to display a block on specific pages just goto the relevant block configuration and under " Show block on specific pages" select "Only on listed pages" define the following

student/*

Now your block will appear only if this URL pattern will match. No matter what you have used to create your block.


Can I allow a user to create a Node using only an embeded rich text editor In Drupal 7, I'd like to present the user with a single text box, that when submitted, creates a new node or entity.

I don't want them to have the standard node/add/type link and interface. Rather, I'd prefer a block that has a CKeditor and submit button. Upon submission, the content of this text box will become a new Node (or entity). The title will be auto-generated.

In some way I'm looking to replicate the functionality of Drupal 6's Facebook-style Statuses (Microblog) -- the same patterns now found on larger social sites: G+, Twitter, Facebook. However, instead of saving to a single database table, I'd like to Drupal to create a new node or entity from that content.

From comments below, I've been pointed towards Rules. However, I'm still having issue with how to go from submission of that single rich text area to triggering a Rule. Would the module Rules Forms Support be of help?

I have done this using:

Automatic Node Titles Module

  "auto_nodetitle" is a small and efficient module that allows hiding of
  the content title field in the form. To prevent empty content title
  fields one can configure it to generate the title by a given pattern.

Advanced Form Block Module

  Welcome to Advanced Form Block Module. With this module you can do the
  following:

  1) Create any number of blocks with a particular node edit form.

  2) create any number of blocks with a particular node add form of a
  content type.

  3) Create as many blocks as you like of each kind.

  4) From the content type choose which fields to display on a per block
  basis.However required fields will be automatically displayed.

  5) All forms will be saved through ajax. So multiple node forms can be
  independently placed on a single page and worked with simultaneously.

With configuration and some css, you can get it looking really nice, and as a block it can go anywhere you want. You can also use hook_form_alter() on the appropriate form:

$form['actions']['submit']['#value'] = 'BUTTON TEXT';

to change the text of the submit button


Twig/Drupal 8 custom cache context not working in node preprocess? I have a twig template that must be rendered differently on smaller displays (mobile devices) or a larger displays. For example, my breakcrumb is moved to the footer for mobile devices.

In order to check the device type, i use Mobile Detect module and i have created a new cache_context named "mobile_detect". I want to use this cache_context in my "node--page.html.twig".

Currently the cache context seems to work only when i'm logged in as "super user" but when i'm not logged in, the node is cached once and the cache context is not used.

Do you have any ideas why this doesn't work ?

Thanks a lot and Sorry for my bad English :(

My preprocess :

function theme_preprocess_node(&$variables)
{
    //mobile detect variable
    $mobileDetector = \Drupal::service('krs.mobile_detect');
    $variables['isMobile'] = $mobileDetector->isMobile();

    //cache context
    $variables['#cache']['contexts'][] = 'mobile_detect';

}

My twig :

{% if isMobile %}
  {# content for mobile device #}
{% endif %}

My cache_context service :

file located in my module modules/custom/customCacheContext/src/Cache

<?php

namespace Drupal\customCacheContext\Cache;

use Drupal\Core\Cache\Context;
use Drupal\Core\Cache\Context\CacheContextInterface;
use Drupal\Core\Cache\CacheableMetadata;

/**
 * Defines the MobiledetectCacheContext service, for mobile or desktop caching.
 *
 * Cache context ID: 'mobile_detect'.
 */
class MobiledetectCacheContext implements CacheContextInterface  {

    /**
     * Constructor
     */
    public function __construct(MobileDetect $mobileDetector)
    {
        $this->mobileDetector = $mobileDetector;
    }

    /**
     * {@inheritdoc}
     */
    public static function getLabel() {
        return t('Mobile Detect');
    }

    /**
     * {@inheritdoc}
     */
    public function getContext($parameters = NULL) {

        if($this->mobileDetector->isMobile()) {
            return 'mobile';
        }

        return 'desktop';

    }

    /**
     * {@inheritdoc}
     */
    public function getCacheableMetadata($parameters = NULL) {

        return new CacheableMetadata();

    }

}

My cache_context service.yml:

services:
  cache_context.mobile_detect:
    class: Drupal\customCacheContext\Cache\MobiledetectCacheContext
    arguments: ['@krs.mobile_detect']
    tags:
      - { name: cache.context }

I finally found the solution. My scripts work pretty well, i just forgot one little thing about the cache modules Drupal enable by default in core.

I needed to disable "internal page cache" module and only keep "dynamic page cache" enabled. In fact "internal page cache" works for anonymous users only and caches the whole page in order to get better performance. It is therefore not possible to create dynamic parts and "max-age" or "cache context" doesn't work. So if you disable the module, drupal uses by default "dynamic page cache" and "max-age" or "cache context" will work then.

I hope this helps you.

More infos here :
http://wimleers.com/article/drupal-8-dynamic-page-cache


can't access www.livesite.com/admin I have just transferred my local server to a live site. I am able to log in as an administrator, but I am not able to access my administrator tools. The page directs me to a blank page. Initially I was able to change the site's theme, through the admin tools, but now I can't even do that. I am not sure what am I doing wrong, or if there is something that I have to change in the settings.php file etc?

Btw, the site update was using ftp only.

A blank page often indicates a PHP Error. Is there an error in the PHP error logs you can reference?

Also, when uploading via FTP, you want to be sure that you properly transferred your .htaccess file which, on some Operating Systems, will be hidden on your local filesystem.


How to load a large amount of users I have to perform actions on about 15000 users.
I'm using a query to retrieve all uids, but the script crashes when using the user_load_multiple

$uids = db_select('users', 'u')
          ->fields('u', array('uid'))
          ->condition('u.status', '1', '=')
          ->execute()
          ->fetchCol();

$users = user_load_multiple($uids);

The script is executed every night, in order to find all users for which the field "Contact again on" (field_contact_on) is empty. If it is empty, we put todays date + 1 year.

Does anyone has a suggestion on how to make this more efficient.

Thanks !

I was running into this issue as well. I ended up using EntityFieldQuery to pull my nodes. Then also went into my php.ini file and set my resource limit params to what I have pasted below.

max_execution_time = 1024     ; Maximum execution time of each script, in seconds
max_input_time = 2048   ; Maximum amount of time each script may spend parsing request data
memory_limit = 5048M      ; Maximum amount of memory a script may consume (8MB)

I've included my php module code below for your reference as well.

// go through player names and search
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'content_type_name_to_pull')
  ->propertyOrderBy('title', 'ASC')
  ->propertyCondition('status', 1);

$result = $query->execute();

if (!empty($result['node'])) {
  $nids = array_keys($result['node']);
  $nodes = node_load_multiple($nids);

  foreach ($nodes as $node) {
    // do what you want with the node
  }
}


Why are these file errors show up on the site - I have "none" selected in admin I'm getting errors like these show up on the site with setting "Error messages to display" set to "none":

File temporary://fileGhQKBK could not be copied, because the destination directory public://css is not configured correctly.

Why do they still show up on the site?

The "Error messages to display" setting only controls whether or not PHP errors/warnings/notices/etc are shown - that particular message is a 'standard' message displayed using drupal_set_message(), with error as the second parameter.

This happens in includes/file.inc, line 891.

drupal_set_message(t('The specified file %file could not be copied, because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.', array('%file' => $original_source)), 'error');

Since there's nothing actually throwing an exception the PHP error handling never comes into it, and the message is displayed as normal.


Combine fields that has same value in views Current view

What I want to achieve

The data are from 2 different entityforms. And then I merged them in my view.
As you can see, in date row, two data(05/29/2014) has the same value.
I want to merge the same value then the field of the 2nd date will align to the first date.

Have you tried using the 'group by' option in views?

Under display, you can select to group by date for example.


Can I create a node, assign a language and provide it a menu link with Drush? Just that. Can I create a node, assign a language and provide it  a menu link with Drush?

Let say, I want to create a node:

of the basic content type
with title set to "my title"
set to es language
and provide it  a menu link in the Main menu

Not out of the box. See this prior related question, all of these examples are created through the Devel 'generate content' library but they assume generic (ex. lipsum) content. For a custom build like you are asking with a specific title, you're best bet is going to be to create a custom Drush plugin using node_save to programmatically create a node with the values you want.


Conceptual help needed for creating forms related to parent node I would like to ask for your opinion in creating a solution for the following application requirements. The general purpose of the application is to administrate students, teachers and courses much like a school administration software.

Some content-types will have related forms (original format is PDF) that are filled in partially by the user and partially by the application.
After filling in the required data, the forms must be printable (PDF) and stored for future editing and printing again. The filled form must always stay related to a specific parent node. Means, if the user views or edits the content of a certain node, he needs to see the related forms and be able to click on them to fill in data or edit or print the filled in form again and again.

A small example.

Content-type: student (node)

- related form: attendance
- related form: enrollment

Properties of the related forms:

- original forms are available as PDF files
- some fields are filled in programmatically, taking data from the currently viewed student node
- other fields are filled in manually by the user
- filled in forms need to be printable (PDF) or send as mail attachment
- filled in forms need to be stored for future printing / editing
- forms always need to be related with their parent student node

My targeted solution is as follows using as example the form "attendance":

programmatically create and validate the form "attendance"
store the filled form as a PDF file in the file system
add the PDF as attachment to the related student node
add an edit button beside the attachment that leads the user to the filled form (for editing and printing again)

Could this solution work?
Does anybody have ideas or hints for a better solution?
Any comments are very appreciated.

I would solve this a bit differently:

Programmatically create and validate the form "attendance" - sounds good.
I would create a separate database table and store the filled form data there. It should have node (and user) id fields to determine to which node (user) it is related to. The node id field or node and user id field combination should be unique so you can always get the right attendance data for the specific node/user. Optionally it could have a unique, auto-incremental attendance id as the primary key if more than one field would be needed otherwise (easier to create unique paths for every attendance). Then I'd also add either separate fields for every form field or one field for all the data (serialized) depending of the needs.
Add a link instead to a programmatically created path (example: attendance/1/pdf where 1 would be the unique id for the attendance). When the user goes to the page create the pdf from the attendance data that they can download/view.
Add a link to the attendance edit form page (example path: attendance/1/edit).

One more thing to note is to get the (view/edit) permissions right if there is a need for restrictions.

In case my solution idea doesn't fit too well with all the specific requirements I would just say that you should store data in the database not files.


Possible to change cron link? I use D6. Cron run often by some bots visiting example.com/cron.php Is it possible to change it somehow? Or restrict? I would like to prevent anonymous users to hit the script.I want to be able to run cron from drupal admin interface and also to run it automatically from linux crontab. I tried to set permissions to read for owner only (www-data is group) but it does not help.

Thank you.

Have you looked at Elysia Cron? I have it installed on all my sites as it allows finer control over how cron is run and has "Protection from external cron calling by cron_key or allowed host list"


How can a text field be re-sized by touch and drag with finger in Smartphone devices Hello Drupal Masters,

I have used Bootstrap template for my Drupal 7 website.
When in Smartphone devices such as iPhone or Samsung phones, i tried to touch the screen using my finger to drag to resize the text field vertically (see screenshot) larger, so the text field could display all text simultaneously.

Whatever i do, I can't re-size the text field when using my finger. It works only with a mouse.

Does anyone know to make the field realizable in touch mode using fingers?

Thank you very much in advance for you tips & Tricks.

Regards
Kim

You might need to implement a custom module that just loads a library similar to this one:

http://interactjs.io/

Scroll down to the resizing section and then check out the demo. You could presumably do this for your input fields.


Create a field linked to a vocabulary with Drush Let's say I have created a taxonomy vocabulary called ABC.
For this vocabulary ABC, i want to create many fields using Drush.

I've tried

drush field-create ABC myfield,text,text_textfield

It works, doesn't give any error, but if I go to the admin panel, I click on structure => taxonomy then in the list I see ABC, I click on "Edit" then I click on the tab "Manage fields" where I expect to see my field. Because (correct me if I'm wrong) I think that the drush command line field-create ABC myfield should have added it. But no.

It's not there. But if I click on the combo of the "Add existing field" option, in the list, there's the myfield that I've just created!

It seems there "link" between ABC and myfield is not created. myfield is  created, but it's not "included" in the ABC fields.

Am I doing something wrong, or missing something?

You are missing Entity type. See the documentation from drush

  Create fields and instances. Returns urls for field editing.

  Examples:  drush field-create article                Define new
  article fields via interactive prompts.                        open
  drush field-create article         Define new article fields and
  then open field edit form for refinement.   drush field-create article
  Create two new fields.
  city,text,text_textfield
  subtitle,text,text_textfield

  Arguments:  bundle                                    Content type
  (for nodes). Name of bundle to attach fields to. Required.
  field_spec                                Comma delimited triple in
  the form: field_name,field_type,widget_name. If widget_name is
  omitted, the default widget
                                             will be used. Separate multiple fields by space. If omitted, a wizard will prompt you.

  Options:  --entity_type                             Type of entity
  (e.g. node, user, comment). Defaults to node.

As you can see the entity type defaults to node . So you have to specify the entity type as taxonomy_term.

  drush field-create ABC myfield,text,text_textfield --entity_type=taxonomy_term


The simplest way of get an emerging modal window I want to open a modal emerging window, with some HTML on it and a close button. It should open when the user visits the page. What is the simplest way of doing that and what modules should I use? I have tried with CTools and a javascript (jQuery) emulation of click on a hidden link, but that gives me problems and seem so convoluted to me. Is there any simplest way?

You can check one of the module:

Splashify
Pop-up announcement
Popup On Load


How do I remove the information section available below the comment box? As shown in the image, below the comment text-area there is an information section I do not want to show. How do I remove the part highlighted in red?

I want the comments to appears as they do on StackExchange, where user just have a text-area for entering their comments.

Simplify module is what you are looking for. Besides hiding the text format selection, it has a few more settings to hide, which really "simplifies" the user interface.

  Simplify allows particular fields to be hidden from the user interface. This helps to de-clutter forms and present a more user-friendly experience to content editors.


How to theme a paragraph bundle with a template file? I am using the Paragraphs module version 7.x-1.0-beta6 I have a bundle with the machine name: text_buttons

In the paragraphs module there are two theme suggestions:

 paragraphs-items.tpl.php
 paragraphs-item.tpl.php

if I copy paragraphs-items.tpl.php to my template folder under my theme, i can modify the code and see the changes reflect site wide wherever there is a paragraph bundle.

Now when I go to target a specific paragraph bundle nothing happens at all.
I've followed the solutions in the following threads:

https://www.drupal.org/node/2326443
https://www.drupal.org/node/2481339
https://www.drupal.org/node/2399631

Nothing seems to work. Is the module currently broken? do I have to implement some sort of theme hook? I've made sure to flush caches on every change just to ensure I would be seeing the template file but it doesn't work, I've never had a problem with finding theme names before.. The documentation is non-existent for this module, and i really don't want to dig into the module code right now.

Another thing to note is that paragraphs-item.tpl.php does nothing on my website from either the module or my theme directory. it seems only paragraphs-items.tpl.php works out of the box.

I've tried:

paragraphs-items--text-buttons.tpl.php
paragraphs-items--text_buttons.tpl.php
paragraphs-items-text-buttons.tpl.php
paragraphs-items-text_buttons.tpl.php

field--paragraphs-items--text-buttons.tpl.php
field-paragraphs-items--text-buttons.tpl.php
field--paragraphs-items--text_buttons.tpl.php
field-paragraphs-items--text_buttons.tpl.php

field--paragraphs-items-text-buttons.tpl.php
field-paragraphs-items-text-buttons.tpl.php
field--paragraphs-items-text_buttons.tpl.php
field-paragraphs-items-text_buttons.tpl.php

Anyone have an idea why I can't theme my paragraph bundles?

I had the same question. Here's what worked for me with: Drupal 7.41, Paragraphs 7.x-1.0-rc4.

Go to the end of your settings.php file and remove the hash sign to enable
"$conf['theme_debug'] = TRUE;" Or add the line if not present.
Flush your cache.
With your favorite browser, inspect the Paragraph output that you
want to override. You should now have HTML comments, just before the
actual markup, with template filename suggestions that you can use
in your theme.

With my setup, the template filename suggestions are:

paragraphs-items--{field name}--{view mode}.tpl.php
paragraphs-items--{field name}.tpl.php
paragraphs-items.tpl.php

Where field name is the name of the field you use when you assign the paragraph field to a content type (not the Paragraph bundle name).

So in your particular case, if the paragraph field happened to be named "text-buttons" (machine name "field_text_buttons"), the filename suggestions are:

paragraphs-items--field-text-buttons--full.tpl.php
paragraphs-items--field-text-buttons.tpl.php
paragraphs-items.tpl.php

Don't forget to turn off theme debugging on your production site.

Best of luck.


How can I get a custom module's file path in a preprocess function? I've got default images located in a custom module directory and I'd like to load them using hook_preprocess_node(). I then will pass the images to the template file.
In the screenshot, I'm loading an image into $default_image, which renders correctly when passed to the template file.
Instead of loading the image from an entity field, I want to read the image directly from the directory in the custom module. Clearly, the path I manually built into $premier_tech_image is incorrect.

The problem is NOT how to access the file. For example, we use code like this for JSON feeds.
$module_handler = $this->moduleHandler;
$module_path = $module_handler->getModule('my_custom_module')->getPath();
$resource = $module_path . '/resources/countries.json';

How do I correctly pass the reference to an image located in the directory of a custom module to the template file?

A Drupal URI starts with a stream wrapper like "public://" that indicates to Drupal how to handle that resource. Typically, the "public" stream wrapper is defined as "treat this resource as a local file within sites/default/files."
Your module assets are not located within sites/default/files, so they cannot use the "public" stream wrapper.
Drupal doesn't actually come out-of-the-box with a registered stream wrapper for module or theme assets. You might try installing https://www.drupal.org/project/system_stream_wrapper, which would then allow you to make a URI like module://tableau_partners_sync/images/premier-technology.png.


how to get css "background-color" value from content types I have a custom type, and I want to set background-color of it,when end user choose the color in add content page,
        example :  set background-color : black
, I want get this value from database, and set style in my theme.
how to do this?

Drupal 7

What you can do is have a field or just for an example a simple textfield and you can use hook_node_view() or template_preprocess_node() to get the color value and use drupal_add_css(). An example would be like:

OPTION 1 - Module layer

/**
 * Implements hook_node_view().
 */
function YOURMODULE_node_view($node, $view_mode) {

  // We check if the user is viewing the node/page in it's full view
  if ($view_mode == 'full' && $node->type == 'page') {

    $field = field_get_items('node', $node, 'field_background_color');

    // Check if the field has a value
    if ($field) {

      $color = field_view_value('node', $node, 'field_background_color', $field[0]);

      // We specify the type to inline and group so it would override any style.
      drupal_add_css("#main-wrapper { background: {$color['#markup']}; }",
        array('type' => 'inline', 'group' => CSS_THEME)
      );
    }
  }
}

OPTION 2 - Theme layer

/**
 * Implements template_preprocess_node().
 */
function YOURTHEME_preprocess_node(&$variables) {

  // We check if the user is viewing the node/page in it's full view
  if ($variables['view_mode'] == 'full' && $variables['type'] == 'article') {

    // Get the node object to be used later
    $node = node_load($variables['nid']);

    $field = field_get_items('node', $node, 'field_background_color');

    // Check if the field has a value
    if ($field) {

      $color = field_view_value('node', $node, 'field_background_color', $field[0]);

      // We specify the type to inline and group so it would override
      drupal_add_css("#main-wrapper { background: {$color['#markup']}; }",
        array('type' => 'inline', 'group' => CSS_THEME)
      );
    }
  }
}


How to grant Userpoints after adding a comment once? I created a Rule that grants Userpoints to users when they comment on a node. However, I would like to grant these points only once per node per user. That means future comments from the same user on that node should not result in extra points.

How can I do that?

I solved my problem with the Flags module: I created the flags called 'Commented on this node' & 'First reaction'* and rule called 'Commented on a node'. These are my rule's settings:

EVENTS: After saving a new comment

CONDITIONS:

Content is of type Parameter: Content: [comment:node], Content types:
Article
NOT Node is flagged Parameter: Flag: Commented on this node, node:
[comment:node], User on whose behalf to check: [comment:author]

ACTIONS:

Grant points to a user Parameter: User: [comment:author],
Points: 2, Points category: Reaction, Entity: [comment:node],
Description: New reaction, Operation: Add,
Display: false, Moderate: Automatically approved
Flag a Node Parameter: Flag: Commented on a node, Node:
[comment:node], User on whose behalf to flag: [comment:author], Skip
permission check: false
Flag a Comment: Parameter: Flag: First reaction, Comment: [comment],
User on whose behalf to flag: [comment:author], Skip permission
check: false

So, every time a user adds a comment to a certain node for the first time, the node is flagged as 'Commented on a node', the reaction is flagged as 'First reaction' and the user who added the comment is rewarded 2 points.

**I use the 'First comment' flag in a related question.*


Views: How to display a grouped taxonomy list with node count? I'm building a classifieds section of a website. Is it possible to create a grouped taxonomy list (by parents) with a node count at the end?

Essentially this is what I want to appear:

Currently, this is my BuySell content type node.
I have two taxonomy vocabularies: BuySell Category and Location.

Lastly, here is a snapshot of my taxonomy vocabulary buysell:

I'm trying to use Views to create the list, however I'm not sure how to get them to group nicely together by parent terms. I can output all terms though.

Any help is greatly appreciated.

It has been a while since I've done this, but I recall doing it with Views and setting the Taxonomy Term as the argument and using the Glossary option.

Alternatively, there are several snippets for doing this type of thing, as I recall. You can find a few of them here:

Show a list(x) of taxonomy terms with node counts
Drupal API - taxonomy_get_tree (or for D7)

In both cases, check the comments for various implementations or tweaks to functionality.


Easily theming Form Fields - How to get minimum HTML required for form field in Drupal 7 I'm using my own templates to modify forms, i.e. user registration form. In my custom template, I call drupal_render($form['field_email']); to get output for a text input used for taking user's Email.

However, this function returns so many outputs (including a Label which definitely I don't want, and a lot of divs) that break my design. What I require is a single <input name = "appropriate-name" /> but I'm getting:

  Email *
 <input type="text" id="edit-field-user-email-und-0-email" name="field_user_email[und][0][email]" value="" size="60" maxlength="128" class="form-text required" />

A lot of HTML!

Is there a way to get minimum HTML required for a form input field to work properly?

Perhaps, I may end up with editing the #theme property for this field, to specify a custom theme function. But That's a lot of work to do, I think. Besides, I have many other fields for which I may need to write custom theme functions to get simple HTML for the input. Is there a quick way to get minimum HTML for a form field?

I can't advise that you remove the labels as your website will instantly become inaccessible and fall foul of disability discrimination guidelines.

That being said, you can override the output for all form elements by implementing an override of the theme_form_element function. The easiest thing to do would be to copy that function in its entirety into a function in your site's theme called MYTHEME_form_element(&$variables), and then step through the code trimming out the elements that you don't want to be output.


How do I get translated strings into Drupal.locale.strings? So I'm trying to use the Drupal.t() function in some of my custom Javascript code (in my theme).

How do I get the strings I need populated in the Drupal.locale.strings object? I see some strings in there, but of course the entire database can't be loaded. What's the best way to add to it? I would like to use the PHP t() function so that the strings added can be edited in the Translate interface.

Drupal handles populating the needing strings into the javascript object. Much like the entire collection of strings isn't loaded on every page, only the needed strings are added to the JavaScript.

I believe this is done by traversing the script files before they are actually added to the page.

So if you add Drupal.t('Some string'); to your JavaScript code, you should be able to translate that in the translate interface.


Different fields of same content type to different roles I have a content type 'new resource'.

I have the form displayed as a page. I would like to make it so that form contains an image field for the admin role, but have this field hidden for any anonymous user filling out the form.

I have been trying to use 'Rules':

EVENTS content is viewed

CONDITION content is of type... Parameter: Content: [node], Content types: new resource AND... NOT User has role(s)... Parameter: User: [node:author], Roles: administrator

ACTIONS Remove an item from a list
Parameter: List: [node:field-web-resource..., Item to remove: [node:field-web-resource..

This might be completely the wrong way to do it, and there is a simpler way, or the Rules approach might work.

When I try to add the ACTIONS the dropdown box keeps showing me things like this:
node:field-web-resource-image-main:0 (Image)
node:field-web-resource-image-main:1 (Image)
node:field-web-resource-image-main:2 (Image)
node:field-web-resource-image-main:3 (Image)

I'm guessing that this is because I have an unlimited amount of images available for upload in this field.

Any help would be most welcome.

Go to /admin/build/modules/list and enable "Content Permissions" under the cck group.

Then go to /admin/user/permissions. Here under "content_permissions module" section  enable permissions for the fields you want to be displayed for authenticated users or anonymous users.


Sort 2 views in a page by 2 different ways I have a simple view, i create a page and a block for view and place them in a page, but How can I sort them in different way:

View Page (sort with nid : asc)
- View Block (sort with nid : desc)
- How can I do this with php field (use with Views_PHP)

Have a nice day
THanks.

Well, as I understand,

You have created a 'page view' and a 'block view'.
Now you want those to be sorted in two different ways.

Well, that's straight forward. But I got a confusion with your statement '..and place them in a page..'. Do you want to mean that you shall place your 'page view' and 'block view' in a another page? If so, then it's not the right approach, as you already have a 'page view' which will have it's own URL or, MENU.

Now, considering the feasible scinario where you want to display 'block view' in the 'page view' where both will have same content but in different sort orders, that you can just manage from drupal view's sort criteria.

Hope it helps


How to disable Create new revision option in a node programmatically I am trying to disable the 'Create new revision option' in each existing nodes programmatically.
I tried with below codes but it was not working.

$results = db_select('node', 'n')
->fields('n', array('nid','vid'))
->execute();
foreach ($results as $result) {
$node = node_load($result->nid);
// Disabling the Create new revision option
$node->revision = FALSE;
node_save($node);
}

Can anyone help me on this? Thanks.

Code you have mentioned in your question solves the problem of create new revision or just update with out a new revision when a node is updated programatically in that particular instance.. It has nothing to do with form option in node edit page...

When you do $node->revision = FALSE;

It is just like telling to node your are updating should be saved as a new revision or not when a node is updated at that particular instance of node_save...

Use hook_form_alter to disable this option in node edit page form..

in your custom module implement MODULE_form_alter and check for node id's you want to disable this option..

$form['revision_information']['#access'] = FALSE;

OR

$form['revision_information']['#disabled'] = TRUE;


Problem with adding checkbox to a view of flags with webform view So, I've been trying to implement a 'sample request' type webform using Flag, Webform, and Webform Views. The idea is to have a webform with a select list made from a view of Flags as implemented here through a custom moduleProgrammatic Sample Request, Drupal Steve.

The issue I'm having is that I can't seem to get a checkbox to show up in the view. I have followed the instructions at the webform views documentationWebform Views Docs by creating a boolean field with a checkbox widget. I'm Flagging Commerce products.  I have even tried to add a boolean on Flags and add that into the view, but that didn't work either.  Not sure is this is a Flags, Commerce, or Webform Views issue, but I wanted to report this here and see if anyone had any ideas.

Using drupal commerce (irrelevant), session_api, flags, views, webform4, custom content type (product display in my example), custom module.

Works even under anonymouse user

I think it's in select field settings.

Called "Multiple":

webform_flags.module:

    <?php
 /**
 * Implements hook_webform_select_options_info().
 */
 function webform_flags_webform_select_options_info() {
    $items = array();
     if (function_exists('webform_flags_user_flag_sample_requests')) {
         $items['webform_flags_user_flag_sample_requests'] = array(
         'title' => t("User's flagged products"),
         'options callback' => 'webform_flags_user_flag_sample_requests',
         );
     }

    return $items;
 }

 function webform_flags_user_flag_sample_requests() {
     $view = views_get_view('user_flagged_products', TRUE);
     $options = array();
     if(isset($view)){
         $view->set_display('webform_options');
         $view->execute();

         if ($view->result) {
             //$row_class = $view->style_options['row_class'];
             //$attributes = $row_class ? " class='$row_class'" : '';
             foreach($view->result as $item) {
                //dpm($item->field_field_image);
                $options[$item->nid] = '<a>' . render($item->field_field_image[0]['rendered']) . $item->node_title .  '</a>';
         }
         }
         else {
            $options[0] = t("Nothing");
         }
     }

    return $options;
 }

View's settings:


Accessing a list of all node fields Programmatically, in Drupal 8, how can I retrieve a list of all entity reference fields including label and machine name?

I have tried the entity manager service, but it only produces a list of keys without their label, and it is reported to be deprecated.

If something is deprecated then that means there is always an explicitly documented replacement and a change record with code examples.

https://www.drupal.org/node/2549139.

In this case it's the EntityFieldManager/entity_field.manager service. But neither entity.manager nor entity_field.manager provide just field names, both provide a list of field definitions.

As always, share your code and you get more specific answers.

One thing you need to be aware of in regards to labels is that there are field storages (fields in 7.x terms) and fields (field instances in 7.x). A single field storage (= unique field name) can exist on different bundles/node types with different names. So one approach to do what you want would be to start with the field map for your type, then loop over the bundles for each field to get the field definition and that label.


Given a block_id, what would be the most reliable method to decide if the block was generated by Views? I would like to use hook_form_block_admin_configure_alter to add configuration options to the blocks admin, but only if the block is for a View. It's important to add the settings here rather than in the view settings itself, since it will grouped with other additional block settings that are not Views specific.

Thanks!

As Clive said, each block will contain the module name from which it was created in the block configuration. For views blocks, it's views module.

This module information will be available in the form structure itself, like below:

$form['module']['#value']

So you don't need to query the database to retrieve it.

Pseudo code:

function my_module_form_block_admin_configure_alter(&$form, &$form_state) {
  if ($form['module']['#value'] == 'views') {
    // ...
  }
}


Multipage registration form with Ctools I'm trying to follow the tutorial on multipage user registrations at http://www.grasmash.com/article/building-multistep-registration-form-drupal-7-using-ctools, but I'm doing something wrong. As it's written, if I put function hook_form_user_register_alter(&$form, &form_state) {, it throws me a Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE error; however, if I change the &form_state to &$form_state, it doesn't complain.

HOWEVER

It seems as if this form isn't replacing the existing form. There's a button added to the registration form Create new account (the standard Drupal continue button is still there). The rest of the standard Drupal form is still the same (just username and password fields).

Thanks for your help

try this

function grasmash_form_user_register_alter(&$form, &$form_state, $form_id) {
  $form['#submit'] = array(
    'user_register_submit',
    'ctools_wizard_submit',
  );
}


How can i filter taxonomy by another taxonomy term with views (term)? I explain my question :
i have a main content -> travel,
Then i have taxonomy term -> country.

On my taxonomy term country, i put a taxonomy term : "tagcountry" (with words like "dangerous", "safe",...)

My question is simple, how can i create a block with related taxonomy "tagcountry"?

For instance, i would like to have in my taxonomy page country "Syria" tagged by "dangerous", a block with the first 10 countries that are tagged "dangerous".
It's quiet easy to achieve this with "content", but i fail with "taxonomy".

Thanks in advance for your answers !

Edit : I already tried with all contextual filters : nothing worked. Except when i provide a manual value like this (but it's not dynamic) :

But when i want to use "taxonomy ID from url" with specified vocabulary ("Load default filter from node page, that's good for related taxonomy blocks"). It doesn't work...

Finally i found a solution with references module :

https://drupal.org/project/references

If some of you want to use custom taxonomy, may be it's better to use nodes with "node reference" than taxonomy...


On D.O., where to file reports for spam users? On drupal.org, where does one file reports for a suspected spam account?

My google searches have turned out results about a spam module and such.

The only way I know is creating an issue in the webmaster queue. There is a Spam category there.


How to get the $form_state in hook form submit? I need to create a node when a comment is submitted in nodes. There are two content types image and memory and I need to get node ID of the node that a user is inserting comment in it.

Here is my code

function THEME_form_submit(&$form_state, $form_id){
    if($form_id == "comment_node_memory_form" || $form_id == "comment_node_image_form"){
        kpr($form_state);
        //Insert new node
    }
}

Clearly this code won't display the $form_state but I need to some how get the node ID and the ID of the user who inserting the comment. I guess these information are in $form_state but I really have no idea how to get them.

Thanks

If you only need nid of node comment is being inserted inside and uid of comment author then use these codes :

nid exist in : $form_state ['values']['nid']

you can even load node if you need more info about it using :

$node = node_load($form_state ['values']['nid']);

to get info about author use : $form_state ['values']['uid']

if user is anonymous this returns 0


Random page rendering error: A stray renderRoot() invocation is causing bubbling of attached assets to break I have a D8 site that's in development and I am getting this error thrown at random on pages which most of the time render quite happily. There doesn't seem to be any real pattern in it.

I can see that it looks like it's designed to prevent the renderer creating an infinite loop (the code is on line 133 of core/lib/Drupal/Core/Render/Renderer.php), but it isn't really clear what's actually causing it. The log error is pretty useless really.

Anyone seen this and found out the cause? Thanks

The error is caused by Renderer::renderRoot() in a wrong place, see the docs:

  Renders final HTML given a structured array tree.

  Calls ::render() in such a way that placeholders are replaced.

  Should therefore only be used in occasions where the final rendering
  is happening, just before sending a Response:

  system internals that are responsible for rendering the final HTML
  render arrays for non-HTML responses, such as feeds

  (Cannot be executed within another render context.)

Look for renderRoot() in custom code. Check if you need to render at all (most times you need not) and don't render too early, only in theming when there is a render context collecting the bubbled up metadata. Then replace it with Renderer::render().

The random behavior is probably because of caching.


How to add jQuery code only to the node add/edit page? I'd like to execute some jQuery code on a particular element in the node add/edit page of a particular content type. Currently I do that by putting

$(document).ready(function() {
    if (window.location.href.indexOf("node/add/CONTENT_TYPE") > -1) {
        ACTION;
    }
});

in the theme's .js file. It works, but I think the approach is probably not appropriate, as the test unnecessarily runs everywhere.

Could you please suggest an appropriate way?

First, you need to convert your script to be a behavior. Drupal will call defined behaviors, so document ready is not necessary.

Second, you can add this script to specific form pages with drupal_add_js and hook_form_alter.

Use hook_form_alter to hook into node add and node edit forms. You can do a check on the $form_id argument to ensure it is a node form.
Use drupal_add_js to add your script file.

Example:

function mymodule_form_alter(&$form, $form_state, $form_id) {
  if (preg_match('/node_form/i', $form_id) {
    drupal_add_js(drupal_get_path('module', 'my_module') . '/script.js');
  }
}

This file will only load when these forms are built, so, you can also remove the line that is checking the window href in the javascript.

The code above is untested, but a general start in the right direction. This code can be placed in a custom module, or, if your admin uses the same theme, you can place it in the template.php of the theme. I strongly recommend a simple custom module.

Edit

I believe the form id is preprended by the content type in 6. So, to isolate it to one content type:

function mymodule_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'content_type_node_form') {
    drupal_add_js(drupal_get_path('module', 'my_module') . '/script.js');
  }
}

Or you can use hook_form_FORM_ID_alter to target specific forms too:

function mymodule_form_content_type_form_alter(&$form, $form_state, $form_id) {
  drupal_add_js(drupal_get_path('module', 'my_module') . '/script.js');
}

Where content_type is the name of any given content type (article, page, etc).

Example behavior (mymodule/script.js):

(function ($) {
  // you can define multiple behaviors

  Drupal.behaviors.mymodule_behaviorname_one = function(context) {
    // this code should fire automatically when the page has loaded
    console.log('Hello!');
    alert('Hello!');

    // attaching to an element
    $("a", context).click(function(e) {
      e.preventDefault();
      alert('You clicked a link.');
    }
  }

  Drupal.behaviors.mymodule_behaviorname_two = function(context) {
    // this code should fire automatically when the page has loaded
    console.log('Behavior 2');
  }
}(jQuery));

More on JS in Drupal (there are some examples in here for 6.x): https://www.drupal.org/docs/7/theming/working-with-javascript-and-jquery


Problem with using ksm($entity) in hook_entity_insert() As the title states, I've encountered a weird problem with hook_entity_insert():

Array ( [:db_update_placeholder_0] => 1 [:db_update_placeholder_1] => 127.0.0.1 [:db_update_placeholder_2] =>

I get a error screen, and this is what's displayed when I attempt to use ksm($entity).

I also checked the logs:

Warning: Error while sending QUERY packet. PID=18801 in Drupal\Core\Database\Statement->execute()....

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: CREATE TABLE {cache_config}....

This is troubling, as the custom module I'm developing heavily relies on nodes.

I thought maybe this was an issue with the DB, and so I used a new one, but the problem persist. I'll be attempting to create a new Drupal project using the same modules.

Therefore I'm asking if anyone else have encountered anything similar to this and found a solution?

Found another post that provides a solution to my problem:
How to preserve kint output upon form submit redirection?

In my case, while

ksm($entity)

would display nothing, or show errors,

ksm($entity->toArray())

seems to display correctly.

I'm a bit baffled myself why this happens, and will continue to investigate.


Omit blank lines when trimming fields with views I have made a views gets the body field and select:
    Formatter ->summary or trimmed

but the field have blank lines which calculated in the length so I may get empty.

Despite selecting  Remove whitespace but still count the blank lines as it is full of text and so I get empty preview.

Please help .

thanks

I've had a similar problem in the past, especially when making the summary trimmed to a shorter length.

When it tries to truncate certain tags like tables or images that can be quite long - and the number of characters you allow is reached before the table/image has been fully parsed, you can end up with a blank summary.

What I do is that I strip certain HTML tags from my fields that are trimmed to only display paragraphs, etc - not images and/or tables.

Just click on the field to set up the new configuration, and you'll find the option in the 'Rewrite Results' section:

Let us know if this works!


Ckeditor image center alignment option Does anyone know how to include a center alignment option for images in ckeditor?

The image below shows what I see:

The standard ckeditor alignment just adds a CSS float left or right, there is no float:center in css. You could add the plugin to ckeditor and that will give you more options.

A plugin is being worked on for this at the moment. You could download the beta and give it a shot. It goes in the

http://dev.ckeditor.com/ticket/10659

You'll need to install the plugin and add some javascript to make it work. There's another post here that shows the process for the justify plugin:
https://stackoverflow.com/questions/14782152/inline-ckeditor-toolbar-has-no-alignment-buttons-for-h2-elements/14810988#14810988


Increase maximum amount of characters for entity reference field (tag style) I have a Drupal 9 installation running Commerce 2. My products use a taxonomy entity reference field (tag style). There's one products category, where I need to have more references in the tag input field than currently allowed (1024 characters).
I looked it up and found a similar post where someone suggested to write a module to increase the maximum input value like so:
function MODULE_field_widget_form_alter(&$element, &$form_state, $context) {

  if ($context['widget']->getPluginId() == 'entity_reference_autocomplete_tags') {
    if ($element['target_id']['#maxlength'] == 1024) {
      $element['target_id']['#maxlength'] = 3072;
    }
  }
}

So I did that, but it still doesn't let me input more than 1024 characters. Any help would be appreciated. Thank you!

I didn't manage to increase the maxlength of the input, but installed "Autocomplete deluxe" module, which implements the widget input field via jQuery chosen. Now I can set as many values as I like.


How to creat a page display comments list of users I try to make every users of my site can view their own and others' posted comments (like "profile:user comments history").

Although the Tracker module can do it, it is not the way I want: It doesn't display the comment but the title of the article to which the comment belongs to.

I am trying with the Views module 7.x-3. I created a comment type view to display comments and add a relationship "Comment: Author". I am stuck here: user1 can view user2's, user3's "profile:user comments history" so the value of "Comment: Author uid" (Filter criteria) should change with the profile pages.

The path of user profile page is /user/% and the arg(1) is the id of users. So I want to make "Filter critera" -> "Comment: Author uid (= < ?  php echo arg(1) ; ?>)", but it does not work.

If the Views module can't do this, please tell me some other modules (small and simple is best) that could make it.

This is just a simple view: Set up a relationship with comment:node not author; then in your filter criteria add "User: Name exposed" and set your fields.


Customisable Tabbed Content Hi guys i'm trying to create a restaurant menu like below:

I've created a 'Venues' content type, in which it contain the usual Title, Description, Image and another Taxonomy field for Category (Type of Restaurant).

At the bottom i'd like a tabbed menu like the image above. Just not sure how I can go about creating it. Ideally i'd like:

Let the user create up to 4 or 5 tabs
Each tab to have a title (Which is displayed in the section and on the tabs)
Each tab to have X amount of items (Name, Description Price)

Not sure if there's a module that helps with this or if I should use Views somehow or what fields I should add to the content type. Totally baffled.

In my static HTML prototype, I used jQuery UI to build the tabs, will I need to use that again here or again, is there a module that can help with that?

Thanks for your help :)

You can see the jQuery Tabs Field module for this.

  jQuery Tabs Field module allows you to create jQuery Tabs field. Using this you can add upto 7 tabs with tab title and tab body in a node. After saving node, the module will display all these 7 tabs as jQuery tabs.


How to import an SQL file and COMPLETELY erase the previous one I'm having a hard time with buggy modules and need to do a lot of installs, uninstalls and so on.

But even if I uninstall, the modules leave data on the SQL file, and the only way to start from scratch is a new install every time...

How can I save SQL files that will delete ALL older data when imported?

An fresh SQL file that doesn't contain any data of newly installed and uninstalled modules.

I've tried add drop dables and other settings, but it seems that once you install a module...it's too late..it keeps creeping back into the database, sometimes form dependencies also?

You can use drush:

drush sql-drop; drush sqlc < path/to/sql/dump/file.sql

Understand it will drop your entire Drupal db and the second command will rebuild it from your dump file.

You can create a base dump from:

drush sql-dump > path/to/save/dump.sql

Here's the link to the drush commands website, select sql from the menu on the left drush commands


Not getting fieldset as a option while adding new fields in content type I am adding new field in content type and I want that field's Field type to be Fieldset but there is no such option in Field type column.

Can anyone know how can I add new field's Field type as Fieldset

Thanks

There's no 'fieldset' field type as such.

If you want to wrap entity fields in fieldsets, install the Field Group module:

  Fieldgroup will, as the name implies, group fields together. All fieldable entities will have the possibility to add groups to wrap their fields together. Fieldgroup comes with default HTML wrappers like vertical tabs, horizontal tabs, accordions, fieldsets or div wrappers.


Create directory in file system per organic group I am using Drupal 7 and I am creating a content type which is a content of an Organic Group. This content type has a file field and all the Organic Group Members can create a node of that. I want to grouping the files in the file system with directories automatically named by Organic Groups names and some sub directories named by current date and current user uid. User can be member of 2 or more groups, so the file should be copied to all the groups directories that user selects in the create node form. Any suggestion?

It looks like the Filefield Paths module will do what you ask, in particular there is an over view on how to Mix public and private files with Organic Groups and File (Field) Paths

The part I can see it doing is copying the file - but you may not want that behavior as it will quickly bloat your storage.


Pass block configuration item text field value to variable I have a custom block module that has a configuration form of type text_field. If there is a value entered into the configuration form, I want to store that value in a variable.

Here is the configuration hook:

/**
 * Implements hook_block_configure().
 */
function roadmap_block_configure($delta = 'roadmap') {
  // This example comes from node.module.
  $form = array();

  switch($delta) {
    case 'roadmap' :
      $form['roadmap_configuration_form'] = array(
      '#type' => 'text_format',
      '#title' => t('Enter an alternative URL.'),
// the URL entered will be sanitized and attached to hook_block_view(), and ultimately passed to a custom JavaScript file.
    );
    break;
  }
  return $form;
}

If there is a value entered into the configuration form, how can I store it in a variable?

So if this is for admin/editors only, one way to do it is to use the built-in Drupal hook_settings_form in your custom module. Here is a nice DO tutorial: https://www.drupal.org/docs/7/creating-custom-modules/creating-the-configuration-form

So in your case, this could look something like:

/**
 * Implements hook_settings_form() to configure module.
 */
function roadmap_settings_form($settings) {

  $form = array();
  $form['roadmap_url'] = array(
      '#type' => 'text_format',
      '#title' => t('Enter an alternative URL.'),
  );
  return system_settings_form($form);
}

this form will save the value as a system variable 'roadmap_url' or whatever value you enter in the form field's machine name. you'd probably need to call this from some admin page in your custom module like so:

/**
 * Implements hook_menu().
 */
function roadmap_menu() {
  return array(
    'admin/config/roadmap_OR_SOME_OTHER_PATH' => array(
      'title' => t('Roadmap settings'),
      'page callback' => 'drupal_get_form',
      'page arguments' => array('roadmap_settings_form'),
      'access arguments' => array('administer roadmap OR SOME OTHER PERMISSION'),
      'type' => MENU_LOCAL_TASK,
    ),
  );
}

Now you should be able to go to your config page, enter your URL setting and it will be saved automatically by Drupal. To access this variable, you just need to call:

$url = variable_get('roadmap_url');


Autosave Not Working I wanted to provide a feature to autosave the data while adding the article so that user can restore the content in the event he goes to some other page.

For that I am using Autosave module. I have installed it and set it for my content type. But it is not showing any kind of message that form has been saved.
Also I have checked that it is not running in "Stealth Mode", so it must give message that it has been saved.

Is there anything I am missing. I am using drupal 7 and latest version of autosave ie 7.x-2.1

Also it would be better if someone could suggest some other module that helps to accomplish this.

-- Thanks

Autosave module works fine with a multilingual Drupal site.

So I'm assuming that you are working on a single language Drupal site.

In order to make Autosave module work on single language Drupal site, you need to apply this patch file

Edit:

The patch file should be for Autosave 7.x-2.x-dev

Check the actual issue


Seeing if node has been changed in custom submit handler I have written a custom submit handler that gets called whenever a certain content type is edited.

I was wondering if there was a flag in $form_state that indicates whether the node was actually edited vs whether someone is just clicking the save button without actually changing anything.  I am wondering because I would like to perform an action only if the node is edited. Thank you

function hook_form_alter(&$form, &$form_state, $form_id) {
  $form['#submit'][] = '_unpublish_new_product';
}

function _unpublish_new_product($form, &$form_state) {
   // is there a flag in $form_state that indicates if any fields were changed so I
   // could perform a conditional action??
}

As far as I know, there isn't such flag, but you can use entity_load_unchanged() to get a copy of the entity before any change, and compare the field value with the one you get from the form.

The function is called, for example, from node_save(), which contain the following code.

// Load the stored entity, if any.
if (!empty($node->nid) && !isset($node->original)) {
  $node->original = entity_load_unchanged('node', $node->nid);
}

field_attach_presave('node', $node);
global $user;

// Determine if we will be inserting a new node.
if (!isset($node->is_new)) {
  $node->is_new = empty($node->nid);
}

// Set the timestamp fields.
if (empty($node->created)) {
  $node->created = REQUEST_TIME;
}
// The changed timestamp is always updated for bookkeeping purposes,
// for example: revisions, searching, etc.
$node->changed = REQUEST_TIME;

$node->timestamp = REQUEST_TIME;
$update_node = TRUE;

// Let modules modify the node before it is saved to the database.
module_invoke_all('node_presave', $node);
module_invoke_all('entity_presave', $node, 'node');

This means that the implementations of hook_field_attach_presave(), hook_node_presave(), and hook_entity_presave() will get the unchanged version of the node object in $node->original (or $entity->original); if you are writing code for one of these hooks, you don't need to call entity_load_unchanged() because node_save() already did it for you.

Similar code is present in comment_save(), taxonomy_term_save(), taxonomy_vocabulary_save(), and user_save().

if (!empty($comment->cid) && !isset($comment->original)) {
  $comment->original = entity_load_unchanged('comment', $comment->cid);
}

field_attach_presave('comment', $comment);

// Allow modules to alter the comment before saving.
module_invoke_all('comment_presave', $comment);
module_invoke_all('entity_presave', $comment, 'comment');

  if (!empty($term->tid) && !isset($term->original)) {
    $term->original = entity_load_unchanged('taxonomy_term', $term->tid);
  }

  field_attach_presave('taxonomy_term', $term);
  module_invoke_all('taxonomy_term_presave', $term);
  module_invoke_all('entity_presave', $term, 'taxonomy_term');


An error upon trying to execute Drupal Console I installed Drupal 8 into on my localhost, working under Windows 7 with OpenServer.
After it I tried to install Drupal Console using Composer.
Namely, this way

composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader

It installed without errors.
But when I'm trying to execute Drupal Console (with command "drupal"), there is an error on the console:

Fatal error: Cannot use Drupal\Console\Core\Bootstrap\DrupalConsoleCore as DrupalConsoleCore because the name is already in use in D:\OpenServer\domains\palomniki.local\vendor\drupal\console\src\Bootstrap\Drupal.php on line 11

Could you clarify me, how to solve this problem ?

Frankly speaking, I managed to find answers of the error, where they advice to reinstall Drupal Console, but I don't know what they means. I tried to do remove this package, then to reinstall it, but I wasn't able to fix the error.

Drupal console global executable is not at the same version as your current project

go outside any drupal project and
and execute: drupal self-update


How to split region block render? Is it possible to split the rendering of the blocks in a region ? I have see this question Drupal 8 - How to split display the blocks separately in region.html.twig attempting to solve this by using    {{ elements.search}} and I have tried it, but no success yet.

I also tried {{ elements.children[0] }} but this failed as well.

Is there a possible way of getting the array element out individually.

Many thanks

You can iterate through the blocks in this way:

{% for block_key, block in elements if block_key|first != '#' %}
  <b>{{ block_key }}: </b>
  {{ block }}
{% endfor %}

If you just need to know the blocks that are present in a given region, you could use this:

{{ dump(elements|keys) }}

Then you can print each block as:

{{ elements.key }}


How do I validate a number against a list of valid numbers? I want to validate a license number against a list of license numbers stored in vocabulary as taxonomy terms. The returned boolean value should then activate other form fields which are disabled by default.

You can create a custom webform validation.

In a custom module you will need to implement CUSTOM_MODULE_webform_element_alter in which you will define a new validation method.

You have to implement the callback method validate() as it is described in the documentation above.

In your validate method you have to compare the submitted value with your vocabulary terms using something similar to the following code

// ...
$vid = 'vocabularyname';
$terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid);
foreach ($terms as $term) {
    if($value == $term->name){
        // ... found
    }
}

About the 2nd part of you question / conditional enabling of fields

Webform built-in conditional logic probably cannot handle it as it only depends on values and NOT validation state of another field.  Perhaps it can be done using conditional_fields but I have not personally tried it.


How to export workflow summary view? I customized the workflow summary view to make multiple views for different users/workflows.

When I try to export it with features, module.views_default.inc is not created, no error (nor notice) message is issued, and the workflow_summary view is deselected from the feature (re)creation form. I've created a feature with only this view, and then get an empty feature.

Is there a way to export it ?

Found that it's better to clone the view to export it as usual than edit default one.

There's also an "export" button on the view definition page that can be used to copy-paste definition manually.


Creating a new Workbench view showing recently updated content and its state This is a simplified example to show my problem.

I've added a handful of Workbench moderation states (and plenty of transitions) into my workflow system.

I need to create a new table view to display content with the following columns:

Title
Revision review date
Moderation state

(I want to either add an external filter on the moderation state, or separate the states out into multiple displays).

This is what I've done:

Created a new view of Content revisions
Added a Workbench Moderation: State field using the relationship to the Content revision
Added sort criteria of Content revision updated date descending to show most recently updated nodes
Removed the 'Published' filter - as the content under review might not be published yet.

However, what I see is repeated content. After adding a filter 'current moderation' I know that to reduce the duplicates, it would be necessary to add a filter 'Workbench Moderation: Current (Yes)'. However, after adding this filter, the list doesn't show the current moderation state. Is this a bug?

I think I figured this out, actually.

Create a new View which lists "Content revisions" (not just "Content"). "Save & continue."
On the View edit screen, open up the "Advanced" right-hand column, remove the "Content revision: Content" relationship from the "Relationships." This causes the View to query the node_revision table, but join the node table in the vid field, which isn't what we want (because node.vid will not always point to the latest revision). Instead, add the "Content revision: Content: The revision NID of the content revision" relationship. Even though this one is also labeled "Content revision: Content," it'll join on node.nid instead of node.vid.
From the Filters section, remove the "Content: Published (Yes)" filter. Replace it with a "Workbench Moderation: Current" filter, set to Yes. Don't relate it to the new relationship we just made ("Do not use a relationship").
When adding entity fields, use the "Content (historical data)" ones instead of just the "Content" ones.

This approach seems to be working for my needs so far.

EDIT: In retrospect, I wasn't quite having the same problem as you were after all, since it doesn't sound like you were wanting to show only one revision per node. But I'll leave my answer up in case someone else eventually finds it useful.


Add additional button to login form Drupal 7

I am trying to add a new button or link to my log in form. The button would simply link to another page outside of the drupal framework. I am looking at the form_alter hook but I am not sure if I completely understand how to implement my update.

do I have to update the template.php page?

The form is the login form on the front page. Any help would be great.

I am pretty sure I need something like the following :

<?php
$form['preview'] = array(
  '#type' => 'button',
  '#value' => t('Preview'),
  '#weight' => 19,
);
?>

But I need to add the link. request.php to the button so when clicked it will go to request.php. Also I am not sure where to add this code and how to direct it to my log in form.

You cannot alter a form from a theme's template.php file. You need to create a custom module for that. In this module, you can alter the login form in an implementation of the hook_form_alter() or hook_form_FORM_ID_alter() hooks.

Without some JavaScript, you will not be able to submit the form to a separated URL. What you can do, in your module, is to provide an dedicated validation or submit handler for you button. In this handler, you can redirect to your external URL using drupal_goto().

Something like:

MODULE_form_user_login_alter(&$form, &$form_state) {
  $form['foo'] = array(
    '#type' => 'button',
    '#value' => t('Foo'),
    '#submit' => array('MODULE_user_login_foo_submit'),
    '#limit_validation_errors' => array(),
  );
}

MODULE_user_login_foo_submit($form, &$form_state) {
  drupal_goto('/path/to/request.php', array('external' => TRUE));
}


How do I sort nodes in node_view_multiple()? I created a block with node teasers loaded with node_view_multiple($nodes).

Now I want to order the results:

By Node ID
By the time is was created/updated
Random

Of course I can order them with PHP array functions, but is there a Drupal specific way to do it?

The best way I can think of to do this is using EntityFieldQuery:

$query = new EntityFieldQuery();
  $entities = $query->entityCondition('entity_type', 'node')
    ->propertyCondition('type', 'your_type')
    ->propertyCondition('status', 1)
    ->propertyOrderBy('nid', 'ASC')
    ->propertyOrderBy('changed', 'DESC')
    ->addTag('random') //this gets the query passed through hook_query_alter
    ->execute();

And you will need hook_query_alter to do the random sort because EFQ doesn't do that natively

function icac_custom_query_random_alter(QueryAlterableInterface $query) {
  $query->orderRandom();
}

To get the nid's for node_load_multiple

$nids = array_keys($entities['node']);


delete users and all its related records Is there a way I could run mysql query from the backend to delete all the users and its related records except master-login.

There are some modules that help to do it or a via drush command but I am trying to do this from the backend database.

I am not sure about the how all the tables are maps. instead of figure it out I am trying to get a quick help here.

No.

You can install the Delete All module which provides some command line Drush commands to remove all content and users safely.

  This module is used to delete all content and/or users from a site.
  This is mainly a developer tool, which can come in handy in several
  cases, listed below.

  The usual way to do this is to go to Administer -> Content then select
  all the nodes and delete them. This works if you have a handful of
  nodes only. If you have hundreds or thousands of nodes, then it is not
  a practical solution.

  Another option is to directly delete the nodes from the node table in
  the database. This does not work properly, since there are also
  comments, and many tables for add on modules that needs to be cleaned.

  This is a test site that the client was using for a period of time,
  and they must clean it up before starting with real data.
  You are
  testing something that creates a lot of nodes (e.g. aggregator), and
  want to do it over and over again.
  You created a site in the past and
  want to replicate it again, but with new content.

  Note that for nodes,
  comments and all additions to nodes that contributed modules may have
  added. For users, any additional module data will also be deleted.


Error installing Theme on GoDaddy Drupal 8.4.5 I have goDaddy and installed Drupal 8.4.5, the newest version they have on their Installation. Trying to install the theme Nexus, when I upload the theme from archive (zip file) and click install I get the following error.

  The website encountered an unexpected error. please try again later.

I have tried clearing the cache. I was running Drupal 8.3.2 and it would just go to a blank screen; updating to Drupal 8.4.5 now got me to this error. I have downloaded and tried about 20 different themes. I either get this error or I get that the file is over 2 megabyte and is too big. What am I doing wrong or how do I fix this error?

Based on the two errors you noted:

"The website encountered an unexpected error. please try again later."
the file is over 2mb

It sounds like your web-hosting provider/CPanel account has a limit on file uploads set, and:

a) your Drupal Core update/upgrade wasn't completed successfully

b) you may not have a temporary directory configured properly for unzipping the theme archive.

Recommended course of action would be to:

finish your Drupal 8.4.5 upgrade (or perform a fresh install on GoDaddy).  If you're drupal core codebase was updated, be sure to go to update.php to ensure all Drupal database updates were applied.
Once Drupal Core has been updated and you can navigate the site/add test content successfully, unzip the theme codebase locally and upload the "nexus" folder to your Drupal site's /themes/custom/ folder using either GoDaddy's file manager, ftp, or via version control tools such as git.
With the theme folder manually installed to the server, flush the cache of your Drupal site; go to Appearance, select and enable the Nexus theme.


Remove the X-generator header from the response I want to remove the CMS type and version disclosure , which Drupal is returning in the X-Generator:Drupal 8 (https://www.drupal.org) header.

I am using the following code, but it removes the x-generator header, but I can still see X-Generator:Drupal 8 (https://www.drupal.org) in the browser header response.

function xxx_page_attachments_alter(&$data, &$context1 = NULL, &$context2 = NULL) {
    foreach ($data['#attached']['html_head'] as $key => $attachment) {
        if ($attachment[1] == 'system_meta_generator') {
          unset($data['#attached']['html_head'][$key]);
        }
    }
}

How can I fix my code?

The simplest method is to remove the header in a custom EventSubscriber:

$response->headers->remove('X-Generator');

See https://drupal.stackexchange.com/a/201297/47547 for an example.


Display multi values field as html list In my content type I have two multi values fields for images and embedded videos. Those fields are displayed in view.

I wanted to display elements of these fields in carousel. I found solution on google, but this solution only works when I have more than one items in field.

I didn't manage to do it for one element in the field.

I want to display those fields (no matter if field has one or more items) in html list.

Could somebody give me any advice?

[EDIT]

I try similar solution to @Shoaib Nawaz answers, but because of memory problems I can display values only from $row object.

The part with data of embedded videos look like this:

   [node_data_field_video_field_video_embed] => Array
        (
            [0] => Array
                (
                    [embed] => http://www.youtube.com/watch?v=XnflHoDIwFk
                    [value] => XnflHoDIwFk
                    [provider] => youtube
                    [data] => a:6:{s:20:"emvideo_data_version";i:5;s:23:"emvideo_youtube_version";i:5;s:8:"duration";i:831;s:8:"playlist";i:0;s:9:"thumbnail";a:1:{s:3:"url";s:43:"http://img.youtube.com/vi/XnflHoDIwFk/0.jpg";}s:5:"flash";a:3:{s:3:"url";s:32:"http://youtube.com/v/XnflHoDIwFk";s:4:"size";s:4:"1011";s:4:"mime";s:29:"application/x-shockwave-flash";}}
                    [status] => 1
                    [version] => 5
                    [title] =>
                    [description] =>
                    [duration] => 831
                )

The part of images looks like:

[node_data_field_photos_field_photos_fid] => Array
        (
            [0] => Array
                (
                    [fid] => 18515
                    [list] => 1
                    [data] => a:2:{s:3:"alt";s:30:"System stołów automatycznych";s:5:"title";s:0:"";}
                )

Screen with jcarousel with this stuff (worked only for fields with more than one items):

Now I need to find function to turn this data to html or code it all.

Try to do it with View field template. Edit your view and check for 'Theme information'. View will suggest some suitable field template according to your field and view's name. The most common template of fields is views-view-field.tpl.php

Other specific can be:

views-view-field--<my-field>.tpl.php,
views-view-field--<my-view>.tpl.php,
views-view-field--<my-view>--<my-field>.tpl.php,
views-view-field--<my-display>.tpl.php,
views-view-field--<my-display>--<my-field>.tpl.php,
views-view-field--<my-view>--<my-display>.tpl.php,
views-view-field--<my-view>--<my-display>--<my-field>.tpl.php

Here <my-field>, <my-view>, <my-display> are placeholders to replace actual field, view and display name.

Create any one of template in your active theme directory and
Try print_r(get_defined_vars()); in your template to know available variables/values.


Envoking a web service method with hyperlink I have successful connected website with a web service SOAP. The SOAP PHP library is working great.
So far I've used a forms that corresponds with the web service, but now I want to invoke a specific method of the web service by clicking on some link.
For an example, the web service has a method "Logout" and I want to pass the xml string after clicking on user/logout.
How can I do that?

You can implement hook_user_logout():

function MYMODULE_user_logout($account) {
  // Make your web service call here.
}

That hook will be invoked whenever a user logs out, which includes them clicking on any link to user/logout.


What can I use for something like Google web analytics for a Drupal website? I'm looking for my site to use web analytics so I will be able to track inside my backend on whats going on inside my web.

I am looking for something like Google Analytics but just on Drupal.

Drupal have the Google Analytics too

  Adds the Google Analytics web statistics tracking system to your
  website.

also install the Google Analytics Reports module to track within the site itself.

  Google Analytics Reports provides graphical reporting of your site's
  tracking data. Graphical reports include a dashboard widget for
  admins, a small path-based report in blocks, and a full path-based
  report.


Avoid change for users profile fields Now in my site every logged user are able to change his profile fields (standard fields and custom fields). I am searching a way to avoid this capability for every 'normal' users (in other word i want that only the administrator have this ability).

There is a method to do this via code or via frontend?

You can use the project Edit Own User Account Permission. It adds a new permission to People > Permissions called "Edit own user account". You can then allow specific roles the ability to edit their own account.


Rest full web service API url is changed in d8 I have rest service url for a node in d6  as

https://192.168.1.236/rest_endpoint/node/1140.json

but the same url in drupal 8 is not working at all , for d8 i have  to give

https://192.168.1.236/rest_endpoint/node/1140?_format=json

here 1140 is the node id and 192.168.1.236 is the base url .

As the url is changing i have to modify many scripts .What may be the reason for this ? or is there any workarounds ?

From the related issue:

  Drupal core no longer uses accept headers for routing but rather rely on a _format query parameter, because browser, (reverse) proxy and CDN support is very poor, and hence could lead to severe bugs. See See #2364011: [meta] External caches mix up response formats on URLs where content negotiation is in use for more background.

So it was a conscious decision, to help prevent common bugs out in the wild. I wouldn't advise trying to find a workaround, the motivation for changing it is sound. But if you want/need to, perhaps just a simple rewrite rule that would take requests for *.json and forward them on to *?_format=json would suffice.


How to act based on a styled image is generated? three image styles defined: thumb, medium and large.
By uploading an image, its thumb/medium/large copies are not generated. .    each styled copy of image is generated only when specific style is asked to be viewed.

I want to do something after styled copy is generated. For example, I want to upload medium size of image to my other server with my API copyToMyServer().

How may I do so? Couldn't find hook for this case.

I believe this is what you are looking for.
http://happypixels.com/blog/triggering-creation-imagecache-derivatives-programmatically

Also see the trigger module.
http://drupal.org/documentation/modules/trigger

You can add your desired action to trigged.


How to rebuild registry table? I've truncated registry table, because of the other problems, but now I have problem rebuilding the registry table based on the files listed in the database.

I'm calling registry_update(), _registry_update() or registry_rebuild() to do it:

drush eval "registry_rebuild();"

But then I've the following error which appears:

  Fatal error: Class 'SelectQueryExtender' not found in includes/pager.inc on line 15

By default (on system module install) registry table is empty, so how Drupal fills that table with the proper default data?

The absolutely easiest way to do it, is to enable any module, as that will do it for you. Of course, if you need to rebuild the registry, generally speaking the UI might be unavailable, but drush en [modulename] might be all you need.

If that's not enough, Registry rebuild makes it trivially easy to rebuild the registry. The easiest way to do it, is to install it as a drush extension.

Install the extension, and run drush rr.

The module page has detailed installation instructions and also shows how to run it without drush if necessary.


Error when updating Bootstrap 7.30 to 7.35 Im getting the following error when visting the root of my Drupal 7 project after updating the sites bootstrap theme from 7.30 to 7.35.

Notice: Undefined index: element in bootstrap_menu_link() (line 22 of /Users/Chris/Sites/iss-mw/sites/all/themes/bootstrap/templates/menu/menu-link.func.php).
Recoverable fatal error: Argument 3 passed to l() must be of the type array, null given, called in /Users/Chris/Sites/iss-mw/sites/all/themes/bootstrap/templates/menu/menu-link.func.php on line 52 and defined in l() (line 2481 of /Users/Chris/Sites/iss-mw/includes/common.inc).

Seems to be some issue with the menu-link.func. Anyone know what this could be?

Cheers!

This is probabbly not related to bootstrap theme itself, because the function bootstrap_menu_link() is the same in both versions.
As I can see the error is because the element key is empty

22. $element = $variables['element']

So, when the the function try to call the l() function, throw an error fatal, because is expecting an array as 3rd argument

52. $element['#title'] = l($element['#title'], $element['#href'], $element['#localized_options']);


Change menu options order I am a beginner with Drupal. I have successfully installed it and:

Created the front page. I did it through Content, Add content, Basic page. Then Configuration, Site information and then in the Default front page I put the alias of my Basic page.
Created an Image gallery with ColoxBox plugin. I went to Structure, Views and created a new view. This view is linked to the Main menu in order to obtain a link in the Menu.

The problem is that my Galleries link came before the Home link.

How can I change the order of these links?

Any help will be appreciated.

Go to admin/structure/menu/manage/main-menu (drupal 7) You can drag the menus to set the order. Or give then weight.


Randomizing nodes in a view display I've tried the solutions here:

Display random value from multi-value field in Views

And here

views... two random nodes to vote on

This is what I have:
A content type (Inventory) involving a field collection of up to 10 items with a picture, price, description and a link.

I have a block view created filtered by category (so it shows up when users click on a particular category and a sort filter setup to randomize.

The block view shows field collection items.. but I only want it to show field collection items for one node at a time, then randomize the results.

Currently it's showing more than one nodes' field collection items..  When I refresh the page, it does randomize the results, but it's mixing nodes and field collection items together.  I just want to randomize the node.

You could try the Views Field View module, which allows you to have a view as a field in another view.

So you would set up your view of nodes, filtering by taxonomy term and sorting randomly. Limit this to one result.

Then add another view that just shows the field collection items with a contextual filter for the parent entity id (I can't remember right now what filter you would use).

Then add the second view as a field on the first view.


Display output from custom module in a panel How would I output data from a custom module to be displayed in a panel pane?

I would recommend using hook_block_info() and hook_block_view() to expose your custom content in a block. This gives you Panels support + contextual links should the need for a form arise, and you can set caching settings for the block.


What is the correct URI syntax for using Forena to connect to a Postgres database? I am trying out Forena Reports and in connecting to a Postgres table I set the the Driver Type to Postgres Database and the URI to postgresql://username:password@127.0.0.1:5432/database.

The problem is when try to connect to the database username and password are correctly sent as the database log produces this message.

 FATAL:  database "database password=password" does not exist

I have created a temporary workaround by creating a user with the same name as the target database, by using the URI and omitting database at the end, as in

postgresql://database:password@127.0.0.1:5432/

What is the correct syntax for this URI postgresql://username:password@127.0.0.1:5432/database which allows a user without the same name as the database?

This worked for me:

host='somesite.comOR_IP' dbname='YourDBName' user='DBUsername'