Remove default field theming in a module - drupal

I was just wondering how to remove the default theming divs of a field in Drupal 7, from within a module (so not with a theme function!!).
In my case: I implemented my own field in a module, now I'm using hook_field_formatter_view to display it. I read here that you can implement your own MYMODULE_theme() function in your module to declare a new field formatter.. but some default divs are still there:
<div class="field field-name-field-myfield field-label-above">
<div class="field-items"> <-- this one
<div class="field-item even"> <-- and also this one
<div id="my-own-field-div">
Is there a way to hide/edit them? I know of the template functions but its better to have the code inside the module..

I think you should try Fences.

Related

How to change heading tag of page builder elements in WordPress?

I am using a WordPress theme named "Delaware" which utilizes WP Bakery as its page builder.
The issue with it is that some of their custom elements in WP Bakery don't offer the option to change the heading tag.
Is there any way I can change it by editing the core files or theme editor?
Here's what the inspect element shows:
<div class ="box-title"><h2>Chloe Smith</h2><div class="border"></div>
Or how can I locate the file from where it is coming so that I can edit it?
Domain name: aidenfinserv.com
It is not easy to locate your file unless you give access to a developer. You probably need to make use of add_filter for one of the hooks using this code: https://kb.wpbakery.com/docs/filters/wpb_widget_title/ which goes into your functions.php
I also have a vanilla JavaScript solution for you at the moment which I have tried. You can paste the JavaScript part in your Theme options custom JS or script.js file.
const boxTitlesh2 = document.querySelectorAll(".box-title h2");
document.addEventListener("DOMContentLoaded", () => {
boxTitlesh2.forEach((boxTitleh2) => {
const boxTitleh3 = document.createElement("div"); // Replace with your custom element
boxTitleh3.innerText = boxTitleh2.innerText; // You can replace it with your custom text.
boxTitleh3.setAttribute("class","custom-heading"); // Better for styling purposes
boxTitleh2.insertAdjacentElement('beforebegin', boxTitleh3);
boxTitleh2.remove();
});
});
<div class="box-testi" style="">
<div class="box-title">
<h2>Prisha Matondkar</h2>
<div class="border"></div>
<p class="sub-title">Sydney, Australia</p><span class="dl-icon-quote svg-icon"></span></div>
<p>Highest Quality Accounting Services, They'll Assign Dedicated Accountants to you unlike some other companies. And The Accountants were always cheerful to Listen to my queries. Will Prefer Aiden Finserv instead of hiring our own accounts team</p>
</div>
<div class="box-testi" style="">
<div class="box-title">
<h2>Chloe Smith</h2>
<div class="border"></div>
<p class="sub-title">Chicago, USA</p><span class="dl-icon-quote svg-icon"></span></div>
<p>Aiden Finserv Client Dashboard for accounting services is one of the most unique things among any Accountant Firm. I can manage everything and its easier to have everything stacked up in one place. I have worked with 8+ Accountant firms and has never
seen anything like this.</p>
</div>
Live output:

Reverse do_shortcode() effect

i have created some basic shortcodes [row],[cols] and [img]. I can use them like:
[row cols="2" ]
[col cols="2"]In faucibus[/col]
[col cols="2"][img src="../wp-content/uploads/2014/08/32-300x300.jpeg"] [/col]
[/row]
What this makes is simple, create the following bootstrap structure:
<div class="row">
<div class="col-lg-6 col-sm-6 col-md-6 col-xs-12">In faucibus</div>
<div class="col-lg-6 col-sm-6 col-md-6 col-xs-12"><img src="../wp-content/uploads/2014/08/32-300x300.jpeg\"" alt="\"\""></div>
</div>
I have made this with do_shortcode($content) because in one shortcode can be another shortcode.
The question:
Is possible to take the html result and converted back to shortcode format based on the shortcodes functions i have already defined?
Thank you:)
I've been having the same problem to a simple front-end editor I'm building. I find Visual Composer very large for simple projects.
A possible solution is to use jQuery to read the attributes and contents of, say a div, and generate the resulting shortcode. So, in your case take the values of 'class' and convert to shortcode equivalent.
I hope this helps!

Drupal 7 annoying content output

I have tried overriding all of the following templates:
page.tpl.php
region.tpl.php
block.tpl.php
node.tpl.php
I still at the top of my content region have the following markup:
<div class="field field-name-field-content field-type-text-long field-label-above"><div class="field-label">content: </div><div class="field-items"><div class="field-item even">
Each of the above templates have nothing but the very minimum to spit out $content usually.
What am I missing?
Sounds like you're looking for field.tpl.php. It's one of those template files, like html.tpl.php, that common themes sometimes don't provide default implementations for, so it falls back on the "hidden" implementation that lives in modules/field/theme.

How do I render an Archetypes in a template?

I would like to render a list of Plone Archetypes in custom template.
In my example, I'm searching 'PortletPage' type in the catalog and get 3 items.
Then I iterate on these items and i'd like to display them.
Is there a way to do that ?
I'd recommend looking at the documentation for Plone's TAL templating language as well as the portal_catalog tool.
Here's a quick example based on the issue you're describing:
<div tal:define="catalog context/portal_catalog;
results python:catalog.searchResults(portal_type='PortletPage');">
<div tal:repeat="item results">
<h3 tal:content="item/pretty_title_or_id" />
<p tal:content="item/Description" />
</div>
</div>

How to create custom Style output in views in Drupal 6 ? besides Grid, Table, HTML list?

I need to alter the output of a view that displays in a in a block in order to apply it to some format of a Jquery UI script so I need the following format for a grouped taxonomy query that I'va configured for some node type..
<div id="tab">
<ul>
<li>Tab1Title</li>
<li>Tab2Title</li>
<li>Tab3Title</li>
</ul>
</div>
<div id="tabs-1">Content2</div>
<div id="tabs-2">Content2</div>
<div id="tabs-3">Content3</div>
You need to create a Style Plugin, and expose it to views 2 API.
A complete style plugin is made up of these components:
An implementation of hook_views_api so Views will load your include
files;
An implementation of hook_views_plugins to declare your style
plugin;
An implementation of the views_plugin_style class;
A theme preprocess function for your style theme;
A theme .tpl.php page.
Here is good reference about extending views 2 with custom modules (from which I taken this component list):
http://groups.drupal.org/node/10129
You need to create your own views style-plugin. Look at views_plugin_style_default.inc in your views module folder.
Then go to Style plugins and find out more about how to implement a style plugin from your own module.
You basically implement the hook_views_style_plugins() and then create your own class that extends views_plugin_style.
Best of luck!

Resources