Main Menu
Contact
Popular Plugins
Sign In

In the config array, you can set a new key "templates" to create one or multiple templates. The easiest way to do so, is like this:

"templates" => [
    "page_header",
	"page_footer",
],

This array will then create 2 templates for your Block Type. Be sure to use lowercase characters and underscores only for values and don't start/end with an underscore (minimum characters of 3).

If you've already taken a look at the "Assets" configuration, you may want to add assets directly for this template too maybe. Instead, set a key and a value and the value has to be an array. Within that array you can drop your assets like you would in the main config file.

"templates" => [
    "page_header",
	"page_footer",
	"mobile_template_only" => [
		"assets" => [
			'view.css' => '.test{color:red;}',
		],
	],
],

In case you add assets after already creating a specific template, make sure you remove obsolete files. Since a template without assets will go straight into /templates (as your_template_handle.php), a template with assets will go into /templates/your_template_handle (as view.php). Same goes for the other way around if you first had assets and then want to remove them of course.

Important!

Whenever you add templates, the "view" array in a field is not being used for the specified templates. You'd have to define each of the variables, in case you want/need some. So let's take a look at an example for the Textarea field type.

"content"         => [
	"type"       => "Textarea",
	"label"      => t("The content"),
	"required"   => false,
	"searchable" => true,
	"config"     => [
		"rows" => 8,
	],
	"view"       => [
		"nl2br"  => true,
		"skip_h" => true,
	],
	"templates"  => [
		"some_template" => [
		    "prefix" => "<div class='alert alert-info'><i class='fa fa-info-circle'></i>",
		    "suffix" => "</div>",
		    "nl2br"  => true,
		    "skip_h" => false,
	    ]
    ],
],

You can see that for the normal view, we have set nl2br and skip_h to true. There is no prefix/suffix, so no HTML or code will be added before/after. This should generate the following output:

<?php if (isset($content) && trim($content) != "") { ?><?php echo nl2br($content); ?><?php } ?>

That's pretty clean and easy to see what's happening. Now let's take a look at the template "some_template".

<?php if (isset($content) && trim($content) != "") { ?><div class='alert alert-info'><i class='fa fa-info-circle'></i><?php echo h($content); ?></div><?php } ?>

There you can see the nl2br() is not there, and instead comes the h() wrapped around the value. Also some elements got added because of the prefix/suffix. This way you can style templates really how you'd want them to be.

Ordering/skipping fields in templates

Not yet available, on the todo-list.

Use, by you or one client, in a single end product. The total price includes the item price and a buyer fee.

  • Quality checked by Concrete5
  • Future updates
  • 30 Day Support
  • Concrete5 buyer fee: $35.70
Add to Concrete5 Cart

Use, by you or a client, in 5 single end products. The total price includes the item price and a buyer fee.

  • Quality checked by Concrete5
  • Future updates
  • 30 Day Support
  • Concrete5 buyer fee: $142.80
  • Save an extra: $119.00
Add to Concrete5 Cart

Use, by you or a client, in x/xx single end products.

Upon request, quote will be made and sent to you via email.

  • Quality checked by Concrete5
  • Future updates
  • 30 Day Support
  • Saves extra $$
Request Quote
Released 6 years ago
Updated 1 year ago
Installs 3
Requires concrete5 5.7.5.3
Current version 1.4.5
Skill level Bleeding Edge

Buyer Rating:

5 average based on 3 ratings More information

Got something to say? Need help?

View support forum