How to use a template to replace the field of a view?

I created a Drupal 8 view with a “User ID” field and a “Custom Text” field.

The machene name of my view is :

menu_page_utilisateur 

The “Custom Text” field uses tokens to display user IDs.

I created a TWIG to replace the “Custom Text” field :

views-view-fields--menu_page_utilisateur.html.twig 

It works, but User IDs do not appear.

How to replace only the “Custom Text” field without overwriting the tokens that have been used ?

enter image description here

Custom form in theme template displaying internal server error upon submission

I have a custom form in WordPress theme template but it is displaying internal server error upon submission. There is no error in error.log file regarding this submission. I am hosting my website on bluehost and here is my form

<form method="post"  action="<?php echo get_template_directory_uri(); ?>/formprocessing.php">             <label for="first-name">Name*</label>         <input class="form-control" type="text" id="name" name="volunteerName" required/>         <label for="address">Address*</label>         <input class="form-control" type="text" id="address" name="volunteerAddress" required/>         <label for="email">Email*</label>         <input class="form-control" type="email" id="email" name="volunteerEmail" required/>         <input class="form-control" class="btn btn-primary" type="submit" value="Submit" id=""/> </form> 

In formprocessing.php file I am just displaying some text and upon submission it redirects to this template file but displaying Internal server error.

<?php    if (isset($  _POST['volunteerName'])){  echo "Form working"; exit;  } ?> 

I have spent a lot of time to figure out this issue but still not able to figure out this. Your help will be much appreciated.

How to use a template to replace the field of a view?

I created a Drupal 8 view with a “User ID” field and a “Custom Text” field.

The machene name of my view is :

menu_page_utilisateur 

The “Custom Text” field uses tokens to display user IDs.

I created a TWIG to replace the “Custom Text” field :

views-view-fields--menu_page_utilisateur.html.twig 

It works, but User IDs do not appear.

How to replace only the “Custom Text” field without overwriting the tokens that have been used ?

enter image description here

How to use a template to replace the field of a view?

I created a Drupal 8 view with a “User ID” field and a “Custom Text” field.

The machene name of my view is :

menu_page_utilisateur 

The “Custom Text” field uses tokens to display user IDs.

I created a TWIG to replace the “Custom Text” field :

views-view-fields--menu_page_utilisateur.html.twig 

It works, but User IDs do not appear.

How to replace only the “Custom Text” field without overwriting the tokens that have been used ?

enter image description here

Использование template в C++

Всех приветствую. Пытаюсь понять как использовать template в С++.

Как я понял, удобство template состоит в том, что можно использовать его как-то так:

Вместо создания 3-х методов чтения float, int, byte из файла :

void ReadFloat(){  }  void ReadInt(){  }  void ReadByte(){  } 

Можно использовать что-то типа такого:

template<typename T> T Read(){  T s;   file.Read(s, sizeof(T));   return s; } 

Но в примерах я встречаю лишь вот такое:

template <class T> class MyTemplate { public:   void dump();   T t; };   template <class T> void MyTemplate<T>::dump() {   cerr << t << endl; } 

И использование:

MyTemplate<float> m_t;  m_t.dump(); 

Но тут мне непонятно 2 вещи:

Получается, что для каждого типа данных мне нужно создавать новые объекты?

А если, к примеру, из всего класса мне нужно использовать template лишь к 1 методу, а не ко всему классу?

Я попробовал так:

class FILE_READER{ public:     bool just_something();      template <class T>     T Read();      template <class T>     void Write(T value); };  template<class T>  T FILE_READER::Read() {     T value;              // куда записывать     ReadFile(T, sizeof(T)); }  template<class T>  void FILE_READER::Write(T value) {     WriteFile(T, sizeof(T)); }  // БЕЗ template  bool FILE_READER::just_something(){   // do something... } 

Как можно это реализовать правильно?

Como concatenar variáveis num template do Django

Tenho um templete do Django que recebe dados de uma tabela para exibir a lista na tela, conforme abaixo:

{% block content %} {% for item in itens_lista %}

{{ item.DESCR_ITEM}}

{% endfor %} {% endblock %}

Para cada item lido é gerado um link que abre a edição do item, porém, além da descrição (item.DESCR_ITEM) do item eu gostaria de exibir também o código (item.COD_ITEM).

Hoje exibe assim:

  • Celular
  • Notebook
  • Pendrive

Eu gostaria que ficasse assim: – 001 – Celular – 002 – Notebook – 003 – Pendrive

Antecipadamente agradeço pela ajuda.

How to use a template to replace the field of a view?

I created a Drupal 8 view with a “User ID” field and a “Custom Text” field.

The machene name of my view is :

menu_page_utilisateur 

The “Custom Text” field uses tokens to display user IDs.

I created a TWIG to replace the “Custom Text” field :

views-view-fields--menu_page_utilisateur.html.twig 

It works, but User IDs do not appear.

How to replace only the “Custom Text” field without overwriting the tokens that have been used ?

enter image description here

Theme settings to include different PHP files into template

I’m trying to include a template section into another template under conditions based on the themes settings.

page.tpl.php

<header>     <?php     $  theme_header_style = theme_get_setting('header_style');//the value is 1     $  header_path = "header_tpl_".$  theme_header_style.".php";     include_once $  header_path;//includes header_tpl_1.php     ?>     <h1><?php print $  site_name; ?></h1><!--this works--> </header> 

header_tpl_1.php

<h1>this will show up</h1> <h1><?php print $  site_name; ?></h1><!--this will not work just an empty h1-->  <p>this will show up on page.tpl.php as well</p> 

I’m pulling in header_style from my themes settings and for this example the value is 1. The file it will include is being added, as the html from the file is displaying but any php in the file is being ignored. anything on page.tpl.php is working as expected its only the php content on included files like header_tpl_1.php that is not working.

Update

Now that I know using a PHP include doesn’t work I would like to know how I could include the contents of the header_tpl_1.php into the template prior to Drupal rendering the page, as this clearly would be the solution. The end objective is being able to load different PHP files into page.tpl.php based on a value set in the themes settings. The code in my header_tmp_1.php was removed from page.tpl.php as working code and put into header_tpl_1.php so I know there are no errors in it, as it works if it’s added directly into page.tpl.php. The problem is including content into a template. I need the content to be included prior to Drupal rendering the variables.

Magento 2 – Include Customizable Options in Email Template

I need to include product Customizable Options with price in order email template. For this I have modified the code and added the Customizable Options code. All are showing fine but the Customizable Options is not showing.

Here is my code added in module-sales/view/frontend/templates/email/items.phtml file

<?php $  _order = $  block->getOrder() ?> <?php if ($  _order): ?>     <?php $  _items = $  _order->getAllItems(); ?>     <table class="email-items" cellspacing="0" cellpadding="0" border="0" width="650" style="border:1px solid #EAEAEA;">         <thead>             <tr>                 <th class="item-info" align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px">                     <?= /* @escapeNotVerified */  __('Items') ?>                 </th>                 <th class="item-info" align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px">                     <?= /* @escapeNotVerified */  __('SKU') ?>                 </th>                 <th class="item-qty" align="center" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px">                     <?= /* @escapeNotVerified */  __('Qty') ?>                 </th>                 <th class="item-price" align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px">                     <?= /* @escapeNotVerified */  __('Price') ?>                 </th>             </tr>         </thead>         <?php foreach ($  _items as $  _item): ?>             <?php if (!$  _item->getParentItem()) : ?>                 <tbody>         <tr>             <td class="item-info" style="padding:3px 9px;font-size:11px;font-weight:700;"><?= /* @escapeNotVerified */  $  _item->getName() ?>         <?php if ($  block->getItemOptions()): ?>             <dl class="item-options">             <?php foreach ($  block->getItemOptions() as $  option): ?>                 <dt><strong><em><?= /* @escapeNotVerified */  $  option['label'] ?></em></strong></dt>                 <dd>                     <?= /* @escapeNotVerified */  nl2br($  option['value']) ?>                 </dd>             <?php endforeach; ?>             </dl>         <?php endif; ?>         </td>             <td class="item-info" style="font-size:11px;"><?= /* @escapeNotVerified */  $  _item->getSku() ?></td>         <td align="center" class="item-info" style="font-size:11px;"><?= /* @escapeNotVerified */  $  _item->getQtyOrdered() ?></td>             <td class="item-info" style="font-size:11px;">Rs: <?= /* @escapeNotVerified */  $  _item->getPrice() ?></td>         </tr>                 </tbody>             <?php endif; ?>         <?php endforeach; ?> <tfoot class="order-totals">   <tr class="subtotal">         <th style="padding-right:20px;font-weight:normal;font-size:11px;" align="right" colspan="3" scope="row">             <?= /* @escapeNotVerified */  __('Subtotal') ?>          </th>         <td>            <span style="font-size:11px;" class="price">Rs: <?= /* @escapeNotVerified */  $  _order->getSubtotal() ?></span>          </td>   </tr>   <tr class="shipping">         <th style="padding-right:20px;font-weight:normal;font-size:11px;" align="right" colspan="3" scope="row">            <?= /* @escapeNotVerified */  __('Shipping & Handling') ?>                             </th>         <td>            <span style="font-size:11px;" class="price">Rs: <?= /* @escapeNotVerified */  $  _order->getShippingAmount() ?></span>          </td>    </tr>    <tr class="grand_total">         <th style="padding-right:20px;font-size:11px;" align="right" colspan="3" scope="row">             <strong><?= /* @escapeNotVerified */  __('Grant total') ?></strong>         </th>         <td>             <strong><span style="font-size:11px;" class="price">Rs: <?= /* @escapeNotVerified */  $  _order->getGrandTotal() ?></span></strong>         </td>     </tr> </tfoot>     </table>     <?php if ($  this->helper('Magento\GiftMessage\Helper\Message')->isMessagesAllowed('order', $  _order, $  _order->getStore()) && $  _order->getGiftMessageId()): ?>         <?php $  _giftMessage = $  this->helper('Magento\GiftMessage\Helper\Message')->getGiftMessage($  _order->getGiftMessageId()); ?>         <?php if ($  _giftMessage): ?>             <br />             <table class="message-gift">                 <tr>                     <td>                         <h3><?= /* @escapeNotVerified */  __('Gift Message for this Order') ?></h3>                         <strong><?= /* @escapeNotVerified */  __('From:') ?></strong> <?= $  block->escapeHtml($  _giftMessage->getSender()) ?>                         <br /><strong><?= /* @escapeNotVerified */  __('To:') ?></strong> <?= $  block->escapeHtml($  _giftMessage->getRecipient()) ?>                         <br /><strong><?= /* @escapeNotVerified */  __('Message:') ?></strong>                         <br /><?= $  block->escapeHtml($  _giftMessage->getMessage()) ?>                     </td>                 </tr>             </table>         <?php endif; ?>     <?php endif; ?> <?php endif; ?> 

Can anyone let me know what’s the issue and how to include custom options with price in this template.

Thanks.

Get a list of field variables for template code (D7)

For Drupal 7, how do I access (or generate) a list of all the field variables available for building a template (for a given content type)?

Some context: I used to rely on the (now deprecated) Contemplate module to write my templates. Directly within its interface, it would print a list of all of the available variables, like this:

contemplate

It was quite handy. Now that I’m making disk-based templates and do not have this list generated by the Contemplate module, I’m confused as to how I might produce something similar for use as a reference.