Can I use the Twig template engine in Drupal 6/7?

I do a lot of Django development and I like their templating language. Twig, the new templating engine in Drupal 8, looks very much like it.

How can I use Twig in Drupal 7 or even Drupal 6?

Link:
http://drupaljoomlahosting.com/content/can-i-use-twig-template-engine-drupal-67 Company: http://texasintegratedservices.com
LinkedIn: https://www.linkedin.com/in/texasintegratedservices

Rendering Taxonomy Custom Fields in page.tpl.php

Ahoy all, so, having some issues with displaying specific fields related to taxonomy terms in a page I created (page–taxonomy.tpl.php)

Essentially, I am trying to set a background image to a div, to pull from an image field (field_hero_image)on the taxonomy term. I have this working for normal nodes just fine with the following code:

field_hero_image[$node->language][0][‘uri’]); >) no-repeat center center;background-size: cover;”>

However, been having difficulty understanding how to modify this to pull this same image field from taxonomy terms.

It needs to be in page–taxonomy.tpl.php as it is being pulled before the node.tpl.php is being called (if i understand correctly?)

Any reason I can pull this easily from nodes, and not for taxonomy terms?

Thanks for any help!

Dan

Link:
http://drupaljoomlahosting.com/content/rendering-taxonomy-custom-fields-pagetplphp Company: http://texasintegratedservices.com
LinkedIn: https://www.linkedin.com/in/texasintegratedservices

What is the fastest way to convert a large volume of documents (.html) to drupal nodes

How would you go about creating a large number of nodes from a large number of html documents?

I am trying to create something similar to a book and have a lot of .docx files on my computer. I am aware I should use a wysiwyg editor to clean up the formatting and make it look like I want saving it as HTML. However there is the issue of getting all the .html files uploaded as nodes without having to copy-paste 200+ times.

Any ideas?

Link:
http://drupaljoomlahosting.com/content/what-fastest-way-convert-large-volume-documents-html-drupal-nodes Company: http://texasintegratedservices.com
LinkedIn: https://www.linkedin.com/in/texasintegratedservices

Split node edit tab in several tabs with panels (or programmatically)

I have a content type with too many fields, so that loading node/%node/edit is a pain ! In order to split node edit form in different pages (local task menu tabs) and smaller forms, I used Page Manager.

What I did so far

Enable the Node add/edit form coming with Page Manager, with selection rule node being edited is from foo_type
Add three new custom panels pages in admin/structure/pages, with paths /node/%node/photos, /node/%node/prices, /node/%node/fd ; with selection rule node being edited is from foo_type
Define its menu as local menu tab.
Share foo_type fields between these forms, and add a submit node form to each.
This renders correctly three node edit forms accessible in new local task menu tabs :

The buggy part

If I edit the node from any of these forms :

the fields present in it are saved
the data saved before is still in the database, and also readable in the form fields if I show up the other forms (except for pictures)
But then the data from the fields who were not in the last form edited is not displayed anymore in the node.
If for test purpose, I add general form item from panels (which loads all the fields that haven’t been added individually yet) to any of theses forms, then submitting the form restores the complete node display ! But obviously this makes all the previous work useless.
The Question

Or it’s a misconfiguration, or I suspect that the form API doesn’t manage that way to render forms Panels offers ??

I really need to split node edit form an dI can’t believe this would not be possible with D7 ?! So I’m searching whether a way to patch the submit behaviour of current solution, or a fully programmatic way to split node edit into tabs. The latter might be a heavy coding challenge for me.

Thanks for your contribution!

Revisions :

It’s not necessary to read below for the present bounty. I let parts of the initial question to make Gokul answer more comprehensive.

I added a tab with hook_menu():

function vts_nodedit_menu() {
$items = array();

$items[‘node/%node/photos’] = array(
‘title’ => ‘Images’,
‘page callback’ => ‘node_page_edit’,
‘page arguments’ => array(1),
‘access callback’ => ‘node_access’,
‘access arguments’ => array(‘update’, 1),
‘weight’ => 0,
‘type’ => MENU_LOCAL_TASK,
‘context’ => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
‘file path’ => drupal_get_path(‘module’, ‘node’),
‘file’ => ‘node.pages.inc’,
);

return $items;
}

I enabled the Node add/edit form coming with Panels
then added a variant, with selection rules Current path is “node/*/photos

I now get edit and Images tabs, but both desperately return the fields and display of the other variant. How can I correct this ?

Link:
http://drupaljoomlahosting.com/content/split-node-edit-tab-several-tabs-panels-or-programmatically Company: http://texasintegratedservices.com
LinkedIn: https://www.linkedin.com/in/texasintegratedservices

View slideshow controls are small

I have created a views slide show, It is working fine. I have enabled the Views Slideshow Configurable Controls module to make the arrows for next and previous for the slide show. I have selected configurable controls and black icons from the slide show settings under top widgets. I want it to appear on extreme left and right corners of the content.

Link:
http://drupaljoomlahosting.com/content/view-slideshow-controls-are-small Company: http://texasintegratedservices.com
LinkedIn: https://www.linkedin.com/in/texasintegratedservices

View got vanished after site migration from one server to another

I have a view on home page displaying a table. When I migrated the site from one hosting server to another that same view got vanished. Rest of the views are working well.

I’m not getting why only single view is not getting displayed. Can anybody tell me the reason behind it?

I deleted all the files and re-uploaded the site, at that time it showed me the table. But When I cleared the site cache, the view disappeared again. And it gave the following warning:

Warning:
file_get_contents(public://languages/ja_ilW4k2-B38dzqfYMhylf9l8OO2xpA33gQBXvn43QZ-4.js): failed to open stream: “DrupalPublicStreamWrapper::stream_open” call failed drupal_build_js_cache() (/var/www/vhosts/######/site1/includes/common.inc ファイル 5008行).

Edit: I deleted the view and again imported it. Then again I tried clearing the cache. After I cleared the cache, the view disappeared again. And now it doesn’t appear even if I delete and import the same view.

Link:
http://drupaljoomlahosting.com/content/view-got-vanished-after-site-migration-one-server-another Company: http://texasintegratedservices.com
LinkedIn: https://www.linkedin.com/in/texasintegratedservices

Add external links Drupal 7 on hold

I want to do a simple project:

create a page to add links
Member can add external links and select a category at the same moment. (Visitors, Member) can view the links under the article.
I want this add (module) in Drupal.

Anybody who can help me on this?

Link: http://drupaljoomlahosting.com/content/add-external-links-drupal-7-hold Company: http://texasintegratedservices.com
LinkedIn: https://www.linkedin.com/in/texasintegratedservices

How to add an ‘operations’ link to a custom route in Drupal 8?

I’m implementing a custom entity with bundles in Drupal 8.

In the list of bundle entities page (i.e. equivalent to Node’s Content Types listing page), I would like to provide an extra option to the list of operations, which currently include Edit, Manage Fields, Manage Display, Delete, to let the user create an entity of that bundle. So if this were on Nodes, then it would be like adding an “Add Content” link for each content type in the content listing page, which would take you to
/node/add/{node_type}.

Relevant code I have so far:

Added an ‘add-entity’ option in the links section of the config entity’s annotations:

* @ConfigEntityType(
* id = “bloom_stem_type”,
* label = @Translation(“BloomStemType”),
* bundle_of = “bloom_stem”,
* …
* links = {
* “edit-form” = “entity.bloom_stem_type.edit_form”,
* “delete-form” = “entity.bloom_stem_type.delete_form”,
* “collection” = “entity.bloom_stem_type.collection”,
* “add-entity” = “entity.bloom_stem.add_form”
* }
* )
*/

Note that this points to a route in another entity, the actual entity that this is a bundle for.

That route is defined in (routing.yml):

entity.bloom_stem.add_form:
path: ‘/admin/bloom_stem/{bloom_stem_type}/add’
defaults:
_title: ‘Add BloomStem’
_controller: ‘\Drupal\bloom\Controller\BloomStemController::addForm’ requirements:
_entity_create_access: ‘bloom_stem’

Then I’ve implemented getDefaultOperations on a custom list builder class:

class BloomStemTypeListBuilder extends ConfigEntityListBuilder { …
/**
* Gets this list’s default operations.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity the operations are for.
*
* @return array
* The array structure is identical to the return value of * self::getOperations().
*/
public function getDefaultOperations(EntityInterface $entity) { $operations = parent::getDefaultOperations($entity);

$operations[‘add’] = array(
‘title’ => $this->t(‘Add’),
‘weight’ => 10,
‘url’ => $entity->urlInfo(‘add-entity’),
);

return $operations;
}

However, when I visit the entity bundles list page, there’s an exception thrown about being unable to create a route/path. On step-through debugging this seems to be because Entity::urlInfo() does not appear to use the route set in the annotation, thanks to this line that constructs its own route:

$route_name = “entity.{$this->entityTypeId}.” . str_replace(array(‘-‘, ‘drupal:’), array(‘_’, ”), $rel);

The only documentation I could find on the links part of the annotation just says:

links
Entity URL definitions, referencing to routes from MODULE.routing.yml. ‘canonical’ is the default route for the entity. edit-form and delete-form can also be set. These are mostly used for Field UI. Arbitrary keys canset here. For example, User sets cancel-form, while Node uses delete-form.

Which I took to mean (“referencing to routes from MODULE.routing.yml”) that if I
referenced a route, that route would be used.

Aside: Other things I’ve tried include creating the URL more directly (clearly not the
right way of doing things):

$url = \Drupal::getContainer()->get(‘url_generator’)
->generateFromRoute(‘entity.bloom_stem.add_form’,
[‘bloom_stem_type’=>$entity->id()]);

That generates a valid path, but a string value is not what getOperations is expected to spit out under its url key output.

Can anyone fill me in on how this is supposed to work/where I’ve gone wrong? Thanks.

Link:
http://drupaljoomlahosting.com/content/how-add-operations-link-custom-route-drupal-8 Company: http://texasintegratedservices.com
LinkedIn: https://www.linkedin.com/in/texasintegratedservices

Filter Node Reference options

I’m trying to set up the content types for a site and ran into a bit of a problem.
Let’s say I have a content type called Employee, and a list of taxonomy terms that holds function names.
Each employee is linked to a function so to say using a Term Reference to one of the available function. Like this each employee is either a mananger, a desk employee, or a janitor etc.

In a second content type, I wish to add a node reference to these Employee nodes, but I wish to have the option of only selecting the nodes linked to a certain term, such as manager. As such, when creating a new node of this second content type I should only be able to select managers in my overview.

Is there any way of filtering your available options like this? I saw some other questions mentioning the References module, but these questions didn’t have an answer.

I hope someone can shed some light on this for me.

Link: http://drupaljoomlahosting.com/content/filter-node-reference-options Company: http://texasintegratedservices.com
LinkedIn: https://www.linkedin.com/in/texasintegratedservices

PlaceHolder in comment Form

I want to add a placeholder to my all comment form , here is what i did :

template.php

function ThemeName_form_alter(&$form, &$form_state, $form_id) { if ($form_id == ‘search_block_form’) {
// HTML5 placeholder attribute
$form[‘search_block_form’][‘#attributes’][‘placeholder’] = t(‘Serach …’);

}

switch ($form_id) {
case ‘comment_form’:
$form[‘name’][‘#attributes’][‘placeholder’] = t( ‘Name’ ); $form[‘subject’][‘#attributes’] = array(‘placeholder’ => t(‘Subject’));
$form[‘comment_body’][‘#attributes’] = array(‘placeholder’ => t(‘comment’));

break;
}

}

nothing happend , Any Help ?

Thanks

Update
Finally i could add placeholder to comment form like this

function sizin_form_comment_form_alter(&$form, &$form_state) {
$form[‘author’][‘name’][‘#attributes’][‘placeholder’] = t( ‘Name’ ); $form[‘author’][‘name’][‘#title’]= FALSE;

//Subject
$form[‘your_comment’][‘subject’] = $form[‘subject’];
$form[‘your_comment’][‘subject’][‘#title’] = FALSE;
$form[‘your_comment’][‘subject’][‘#attributes’] = array(‘placeholder’ => t(‘title’));
unset($form[‘subject’]);
$form[‘your_comment’][‘subject’][‘#weight’] = -10;

//Comment
$form[‘your_comment’][‘comment_body’] = $form[‘comment_body’];

$form[‘your_comment’][‘comment_body’][LANGUAGE_NONE][0][‘value’][‘#attributes’] = array(‘placeholder’ => t(‘comment’));
unset($form[‘comment_body’]);

}

But i couldn’t add to textarea(comment Body) ? AnyHelp ?

Link: http://drupaljoomlahosting.com/content/placeholder-comment-form Company: http://texasintegratedservices.com
LinkedIn: https://www.linkedin.com/in/texasintegratedservices