I AM LISTENING TO
|
WAS ICH LIEBE
  • Englisch
  • Deutsch

Extending the Visual Composer Row element with a new property

7. November 2014




Extending the Visual Composer Row element with a new property

Visual Composer for WordPress provides many ways to extend its functionality. There are already many add-ons available for this dynamic page builder, but its easy to do the extending yourself,  by following the hints in the documentation ;)

In this small tutorial we are adding a „type“ field to allow a special css class to be added to each of our row containers.

New Visual Composer element properties can be easily added by using the vc_add_param function. See documentation for more information. In our case we are adding a property to the vc_row element.

ADJUSTING YOUR THEME

By adding the following lines to your themes functions.php, this new property will show in the admin row settings popup.

The new setting will be saved, when you save your document, but you wont see any changes on the frontend yet! Our goal is to switch a css class depending on the type we selected.

Each element within Visual Composer has its own template and these templates can be overruled using your own theme templates. In this case vc_row.php.

  1. Create a new folder „vc_templates“ in your theme or child-theme.
  2. Copy vc_row.php from /wp-content/plugins/js_composer/includes/templates/shortcodes/ to your newly created folder.

BEFORE

The file contents should look something like this:

AFTER

Now we are adding the magic from the backend to the frontend :) This is how the altered version should look like in your theme folder

We added
‚type‘ => ‚in_container‘
to the shortcode parameter extraction, with a default setting.

We also added the resulting type to our row wrapper
$output .= ‚<div class=“‚.$type.‘ ‚.$css_class

Visual Composer allows you to modify any of its elements that way and extend it with your own options or mighty extensions ;) Visual Composer allows some nice custom tweaking, you just need to look a bit closer at the documentation, which is not always that simple to follow :)

Enjoy coding …




Abonnieren
Benachrichtige mich bei
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Marga
Marga
7 Jahre zuvor

Visual composer never was a smart thing. It’s crap, in fact.
Why make it so complicated?
What’s wrong with the good old CSS?
So easy to change any style, layout, etc., with plain CSS. With VC? Waste time and still can’t do what you „Really“ want and otherwise could do with plain, straight forward CSS files.

VC is for idiots and poor hackers (fits WP overall purpose)




Alexander

Ich bin ein Full-Stack-Entwickler. Meine Expertise umfasst:

  • Server-, Netzwerk- und Hosting-Umgebungen
  • Datenmodellierung / Import / Export
  • Geschäftslogik
  • API Layer / Action Layer / MVC
  • Benutzeroberflächen
  • User Experience
  • Verständnis für Kundenwünsche und Geschäftsbedürfnisse

 

Ich liebe die Entwicklung, das Design und kenne mich auch mit Serverarchitekturen aus.  Ich würde mich nie vollständig fühlen, wenn einer der Bereiche fehlen würde.

Ich habe ein breites Interessengebiet, deshalb tauche ich ständig in neue Technologien ein und erweitere mein Wissen, wo immer es nötig ist. Die Technologien entwickeln sich schnell und ich genieße es, die neuesten Technologien zu nutzen.

Abgesehen davon bin ich ein friedliebender Kerl, der versucht, Leute um sich herum zu haben, die dasselbe denken.  Ich glaube wirklich an das Prinzip: "Wenn man jemandem hilft, wird einem jemand helfen, wenn man es braucht."

Previous Next