0

We would like to add blocks of HTML that we have styled in channels. Similar to the functionality of a Wordpress shortcode. So if we need for example a stylized quote that has predefined html and styles, we could insert that anywhere into our channel entry.

In Wordpress if you do [my_shortcode], it can potentially spit out

<div class="example">hello</div>

Or a more robust example

[quote variable="test" img="something.jpg"]

which could spit out

<div class="quote">
 <img src="something.jpg" />
 <p>test</p>
</div>

So we need to be able to have a number of different types of these and use them in any order on channel entries

Also I'm talking about the editor screen on admin when making entries for stuff like blog. So i need to input this php code or html on the rich text editor or somewhere on the editor screen.

0

Sounds like you are wanting either EE's Template Variables or Template Partials.

In either case you define some content and associate it with a custom tag - then whenever EE encounters the tag in your templates, it replaces the tag with whatever content you have associated with it.

From the look of your examples, you probably want to use Template Partials to do what you are trying to do.

From the EE documentation:

In both cases, ExpressionEngine is simply swapping out a tag with the contents of that tag. However, there is a big difference in when that swap takes place,

Template variables are one of the last tags on the template that are parsed, so they are great for static content, meaning content that does not contain other tags.

Template partials are one of the first tags parsed, so if you want to put other tags in a Template partial, those tags will still be seen and parsed just fine.

HTH

| improve this answer | |
  • Hmm, i'm not sure this would work. We need to be able to enter it in the rich text editor, or entry editor screen somewhere. (on the admin dashboard). on a blog for instance. – good_afternoon Apr 13 '18 at 14:06
  • OK - wasn't clear from your original question that you want these expansions to be used by users rather than to build your site. If you are creating information using bloqs however - which requires your users access the EE control panel to use - then there is no reason why you cannot also have them access other parts of the CP interface including template variables of the kind described. – JCOGS Design Apr 17 '18 at 12:22
  • functionality would be for copywriter. has to be simple for them to do – good_afternoon Apr 17 '18 at 14:53
0

Well, I found a third-party plugin that helped me achieve exactly what I wanted, however, it wasn't a free solution. ($100 price tag).

https://eebloqs.com/

You can have your predefined HTML and use the fields from this addon to populate your HTML. You can rearrange in any order on the channel entry page. Use all or none of your fields.

Basically a GUI shortcode. Ideal for clients that don't want to touch HTML

| improve this answer | |
  • Most of what you can do in bloqs can now be delivered (in EE4) using the 'fluid' field type (docs.expressionengine.com/latest/fieldtypes/fluid.html): it lets you pre-define blocks of HTML (or template structures etc) and have the user pick / insert them into the fluid field in any order you like with as many duplicates / repetitions needed. And it comes for free as part of EE4 (so no $100 charge) – JCOGS Design Apr 17 '18 at 12:44
0

If you use WYGWAM and set up "content templates" you can accomplish "short codes" in a WYSIWYG environment. It's actually something better than short codes.

https://www.youtube.com/watch?v=a7zZ7MXX7EM

Have a look at this Youtube video (skip ahead to 3:00 minute mark) to see an example of what it would look like for an editor/content creator to work with.

I have an EE4 site in which I migrated content from Wordpress and had to "expand" all those short codes during import. I used this method.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.