How can i add class inside content on TWIG - Drupal - class

I have this div
<div class="col-md-6 column_must">
<p class="must_title"> {{ content.field_code_must_title }}</p>
<p class="must_desc"> {{ content.field_code_must_desc }}</p>
</div>
I want to insert this 2 class in content, but the result shows the then the content, but i want the content inside in that
Can you help me?
Thanks

You will need to add a twig file to edit the fields field_code_must_title and field_code_must_desc, there you'll be able to add your classes to the fields.
What I would suggest you is on the custom theme folder that you will have on your drupal installation, create the twig files for these two fields and then copy inside the field.html.twig from the drupal core theme and make the changes in place.
Follow this link for more insights:
https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-for-custom-module

Related

Display html element from JSON object on ionic App

I have been trying to embed html element from JSON object, and It is currently displaying the html as raw code instead.
Can someone please help me ?
detail.ts
this.questionsData[i].question_type.title = "<ion-input type=\"text\" placeholder=\"Short answer\"></ion-input>";
detail.html
<ion-item *ngFor="let question of questionsData">
{{question.title}}
<br>
Text : {{question.question_type.title}}
<br>
<div [innerHTML]="question.question_type.title">
</div>
</ion-item>
Isn't it should be input box under the text : , anyone know why it's not rendered ?
Thanks
InnerHtml will only help to render pure html code on run time, you can't use ionic components to render dynamically using innerhtml. I think you need to use dynamic component loader feature in angular here. You can refer this link on use cases of this feature https://medium.com/#DenysVuika/dynamic-content-in-angular-2-3c85023d9c36
Your approach needs to change, do not include html tags in component block, instead add parameters as json data and set it at component. Then you can interpolate the tags in the template view.
Ex:
at the component:
this.inputDataArray = [{"title":"What cartoon do you like to watch?", "name":"inp1","placeholder":"short answer"},{"title":"What movie do you like to watch?", "name":"inp2","placeholder":"short answer"}];
at the view:
<ion-item *ngFor="let question of inputDataArray">
{{question.title}}
<br>
Text : <input name={{question.name}} placeholder={{question.placeholder}} />
<br>
</ion-item>
Its just a reference, Hope it helps
This worked for me.
<div [innerHTML]="data.text"></div>

tinymce on multiple instance of same TextArea

Two instances of a partialview are loaded on a page.
Partialview has a textarea with id 'newNote'. Hence, when page loads we have two textarea elements with same id - 'newNote' but under two different containers.
<html>
<div id='container1' style="display:none">
--partialview
<textarea id='newNote'/>
</div>
<div id='container2'>
--partialview
<textarea id='newNote'/>
</div>
</html>
I want to convert textarea to tinymce Rich text editor based on the active container (in above case container 2).
Can someone pls tell me how to handle two instances with same id.
You should never have two elements on the same page with a non-unique id
HTML4
HTML5

Magento include phtml file within another phtml file

I am making a custom home page for my magento website in a phtml file named home_banner.phtml, which in turn i have referenced in the CMS->Pages->Home Page content by the following code
{{block type="core/template" template="theme/home_banner.phtml"}}
In my home_banner.phtml I have called tags/popular.phtml to display the popular tags.
<div class="last-posts-grid clearfix">
<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('tag/popular.phtml')->toHtml(); ?>
</div>
However the tags are not being displayed even though the anchor tag which says "view all tags" id getting called correctly. The ul class="tags-list" is also visible in the page source but the tags themselves are not visible. Any suggestions?
You made a small mistake in the template file. Your template file has to be as below:
<div class="last-posts-grid clearfix">
<?php echo $this->getLayout()->createBlock('tag/popular')->setTemplate('tag/popular.phtml')->toHtml(); ?>
</div>
I tested this and its working fine.. Hope this helps..

Creating Custom Content Element in TYPO3

Cany anybody tell me how to render the following structure in
typo3 without developing a new extension.
<div class="sidebar-details">
<div class="sidebar-details-title">
<h4><span>MY TITLE</span></h4>
</div>
<div class="sidebar-details-body">
<p>
TEXT
</p>
</div>
</div>
What would be the best/recommended way to achieve this ?
Start using gridelements.
Gives you exactly what you want.
http://typo3.org/extensions/repository/view/gridelements
You can activate the RTE html mode and put it in its source or make use of HTML element, but that's depending on your needs.
If you want to keep RTE functions for editing the text what I mentioned first is the recommended way. Have done it several times myself.
If you are using Template mapping using Templavoila so, you can create FCE(Flexible content element) for it and you can map this part.
If you are using fluid template mapping so, you can create gridelement for it. and map all part.

How can I enable tinyMCE in Umbraco to add a div with a class attribute and contain a paragraph?

I need to allow add a div with a class attribute in tinyMCE in Umbraco. I can add a div, but all content in the div is just text. I need that text has a paragraph, and finally add a class attribute for the div.
It's a little hard to understand what you are asking, but I think this should help.
http://our.umbraco.org/wiki/recommendations/recommended-reading-for-content-editors/adding-styles-to-the-tinymce
You can basically associate a stylesheet with the tinyMCE and then add styles to it that will appear in the style dropdown
You may use
tinymce.activeEditor.execCommand('insertHTML', false, '<div class="section'></div>');
This will insert the specified html into the editor at the local caret position.
Be aware that your valid_elements and valid_children configuration settings won't strip out anything from the html that you insert.
If you can paste your template code then we can be more of a help to you.
What you want to do is wrap your <umbraco:Item field="aliasOfYourRTE" runat="server" />
with the div you want so in your case your code will look like this:
<div class="YOURCLASSNAMEHERE">
<umbraco:Item field="bodyText" runat="server" />
</div>
The umbraco RTE automatically spits out <p> </p> tags when content is inserted. Also, make sure you are publishing your node so that your content is viewable on the front end.
Hope this helps.
Go to Settings - Styles.
Open the stylesheet with the styles for the Format dropdown of TinyMCE in Data Type Richtexteditor.
Add a style with the Alias div.class, e.g. div.alert alert-danger.
If you then click in TinyMCE on a paragraph and then choose in the Format dropdown this style the paragraph is formatted as follows:
<div class="alert alert-danger"> ... </div>
Is this what you wished to do?