Drupal StackExchange

How do I create a sticky navigation bar in Open Social?

2 days 16 hours ago

I'm using D8 and working on new theme in Open Social witch uses bootstrap/sass. In my theme I want the navigation bar (in the header region) to be sticky at the top of the screen. I've made some javascript/sass code but I can't get it to work. This is what I have done so far:

Created a new javascript function in the theme_name.js file:

//-- Sticky Header (function($) { Drupal.behaviors.navbar = { attach: function (context, settings) { var nbar = $('.header'); if (nbar.length) { var elmHeight = $('.header-top').outerHeight(true); $(window).scroll(function() { var scrolltop = $(window).scrollTop(); if (scrolltop > elmHeight) { if (!nbar.hasClass('sticky')) { nbar.addClass('sticky'); } } else { nbar.removeClass('sticky'); } }); } } } })();

This is a code snippet from the navbar.scss file:

.navbar-sticky-top { @include z-depth-3; position: fixed; top: 0; left: 0; z-index: $zindex-navbar-sticky; }

Code snippet from the index.twig file:

<nav class="navbar navbar-default navbar-sticky-top" id="top" role="banner"> <div class="container"> <div class="navbar-header"> ...

This is the content of the region--header.html.twig file:

{% if content %} <nav {{ attributes.addClass('navbar navbar-default navbar-sticky-top') }} role="banner"> <div class="container"> {{ content }} </div> </nav> {% endif %}

What am I missing here?

Søren Sjøstrøm

Is it possible to disable taxonomy hierarchy?

2 days 18 hours ago

The site I am building uses fields (plus a custom module) to provide a richer set of relationships between taxonomy terms than the built-in hierarchy allows.

I want to remove/disable the built-in hierarchy. What I mean is that when a user is creating or editing a term, I do not want them to see the "Relations" section, and when they are viewing a list of terms in a taxonomy, I want the drag-and-drop functionality to only work for ordering, not indenting.

I know I can do this with another module using hook_form_alter() or the like, but is there an easier and quicker way to "turn off" this functionality in Drupal 8? I have a vague memory of (maybe in an earlier Drupal, or somewhere else) being able to specify, when you create a taxonomy, if you want it to be hierarchical or not, but I cannot find such a thing here.

naomi

Change toolbar config to latest CKEditor toolbar groups

2 days 20 hours ago

There is a ckeditor plugin that I really want to use (Line Height), but after looking at its .js file I can see that it is configured to work with the ckeditor config.toolbarGroups concepts, which configures the toolbar like so:

CKEDITOR.editorConfig = function( config ) { config.toolbarGroups = [ { name: 'document', groups: [ 'mode', 'document', 'doctools' ] }, { name: 'clipboard', groups: [ 'clipboard', 'undo' ] }, { name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] }, { name: 'forms', groups: [ 'forms' ] }, '/', { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] }, { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] }, { name: 'links', groups: [ 'links' ] }, { name: 'insert', groups: [ 'insert' ] }, '/', { name: 'styles', groups: [ 'styles' ] }, { name: 'colors', groups: [ 'colors' ] }, { name: 'tools', groups: [ 'tools' ] }, { name: 'others', groups: [ 'others' ] }, { name: 'about', groups: [ 'about' ] } ]; };

However, I use the ckeditor module, with a drupal 7 codebase, and after I install the plugin and its dependencies, the button for the lineheight plugin doesn't show up when I go to admin/config/content/ckeditor/edit/**{text format}**.

Is there a way to edit the lineheight plugin code so that it works with the ckeditor module?

editor.ui.addRichCombo( comboName, { label: editor.lang.lineheight.title, title: editor.lang.lineheight.title, toolbar: 'styles,' + order, allowedContent: style, requiredContent: style, panel: { css: [ CKEDITOR.skin.getPath( 'editor' ) ].concat( config.contentsCss ), multiSelect: false, attributes: { 'aria-label': editor.lang.lineheight.title }

Or, is there a way to convert the ckeditor module to from using the method below to using the new method above?

// Toolbar definition for all buttons Drupal.settings.cke_toolbar_DrupalFull = [ ['Source'], ['Cut','Copy','Paste','PasteText','PasteFromWord','-','SpellChecker', 'Scayt'], ['Undo','Redo','Find','Replace','-','SelectAll'], ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','Iframe'], '/', ['Bold','Italic','Underline','Strike','-','Subscript','Superscript','- ','RemoveFormat'], ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl','-','Language'], ['Link','Unlink','Anchor','Linkit','LinkToNode', 'LinkToMenu'], '/', ['Format','Font','FontSize'], ['TextColor','BGColor'], ['Maximize', 'ShowBlocks'], ['DrupalBreak', 'DrupalPageBreak']
yupthatguy

How to call preprocess functions from my custom module

2 days 21 hours ago

I have created a custom module that declares a custom image formatter. Now I need to call the Core image module preprocess function 'template_preprocess_image_formatter'. How would I do that?

I tried to add it in the list of preprocess functions of my custom theme but it doesn't fire unless I clear the cache:

/** * Implements hook_theme(). */ function foo_theme() { 'image_formatter_foo' => [ 'variables' => ['item' => NULL, 'item_attributes' => NULL, 'image_style' => NULL], 'file' => 'foo.field.inc', 'preprocess functions' => [ 'template_preprocess_image', 'template_preprocess_image_formatter_foo' ] ], }
Eric MORAND

Hide the "view exposed filter" form or reload the page after submit the form?

2 days 22 hours ago

I am using view exposed filter on a view display as "block". The block is added to dashboard.

I added a second function to "Apply" button using hook_form_alter. I want to hide the expose form of view after submit it. I added the jquery to hide the element using drupal_add_js. But it didn't work.

Is there any way to hide the form or reload the page after submit of expose form so i can hide the form on page load?

Sumit Madan

How to programmatically create forums and containers (not forum topics)?

2 days 23 hours ago

I need to create containers and forums using rules.

If I use the action "Create new entity" -> "Taxonomy term" I got that by default the new term created is treated as a forum, not a container. How can I either convert it to be a container or, using a custom PHP script, create directly a container ?

I tought it was some variable of the term to make the difference, but if I use Devel over both containers or forums they looks the same.

I found http://www.unibia.com/unibianet/drupal/how-create-drupal-forums-and-containers-programmatically but it refers to D6, and in D7 I don't know what to pass as $form and $form_state to the forum_form_container() function.

Antonello

Unknown engine type outputformat

3 days ago

Hello I've just updated Drupal (to version 7.53) and now in Drush when I try launch the commands: "drush @theflyingeye.org up" (to update my website) or "drush @theflyingeye.org cc" (to clean chache) or "drush @theflyingeye.org dl view" (to download a basic module, view for example) I can just get this answer: "Unknown engine type outputformat"

If I digit:

"drush status" (after "su aegir") I can get: "PHP configuration : /etc/php5/cli/php.ini Drush version : 5.10.0 Drush configuration : /var/aegir/.drush/drushrc.php Drush alias files : /var/aegir/.drush/server_master.alias.drushrc.php /var/aegir/.drush/theflyingeye.org.alias.drushrc.php /var/aegir/.drush/server_localhost.alias.drushrc.php

Do you have any advise please to fix this problem?

Gilles9999

Filters as rewrite results link path parameters

3 days 1 hour ago

I am currently using this approach to link lists view's rows to detail pages in Drupal 8


I would like to pass the entity title of the row to the receiving page and use that to select view blocks having that title.
In this case something like www.mysite.com/VenuePage?Name="Mikes" This argument would then be used to select blocks with Title "Mikes"

Can someone point me in the correct direction? I'm a bit new to Drupal and may be thinking about this incorrectly.

Robert

Drupal Planet

LN Webworks: How To Use Cron Jobs For Task Automation In Drupal

2 days 16 hours ago

The efficiency of any website is a must in this fast-paced world of web development. One of the most important tools to maximize the efficiency of your Drupal site is cron jobs. 

Cron jobs are powerful tools that automate any kind of routine tasks of the website which decreases the big load of a developer or site administrator. In this article, I will give you important insights about cron jobs and how we can use them within Drupal, followed by how we customize the tasks by overriding services of the ultimate cron job module.

What is Cron Jobs in Drupal? 

Cron in Drupal works quite well as it coordinates all the backstage tasks. It handles everything from clearing caches to checking for updates of any kind of content and executing scheduled tasks set by your modules.