Is there a way to add own shortcodes to the module and would it be possible to integrate them into the tinymce module?

yes

Comments

denes.szabo’s picture

You just have to see into the shortcode module dir: there are two other module which use the shortcode api. These modules defines own shortcode tags.

You have to only enable the shortcode for your input format. It is not matter this input format uses tinymce or not, the shortcode will work. I use it with tinymce too.

I know I have to write a good documentation... This task in my queue...

brenes’s picture

Thank you for your reply. By using the code in your shortcode_basic_tags.module as an example I figured out how to add shortcodes on a programmatical basis. As a future extension I could imagine that it would be neat if the user is able to add the Shortcodes in the drupal backend.

I think you misunderstood me with the tinymce implementation. I would like to add a dropdown (or anything else) to tinymce from which I can select the appropriate shortcode, which then gets inserted in the textarea. Or another Idea is that I have the shortcodes presented under the content field - like they are now through your shortcode_basic_tags.module - and when I click on one that it gets inserted in the content field. Because I think the copy and pasting of the shortcodes is to much of a hassle for a non experienced user.

Any Ideas?

denes.szabo’s picture

You are right: boring and easy mistype the codes.

I think, there should be an interface for wysiwyg api and the enabled shortcodes automatically should insert themself into the content editors. But, I have no idea how it can be. I haven't seen the wysiwyg api yet.

I am thinking about it.

brenes’s picture

StatusFileSize
new71.86 KB
new12.98 KB

I have seen a similar function in a wordpress theme I used for a customer. They are using a custom Plugin for tinymce, so that you can add your shortcodes with a pulldown menue. Probably you like to have a look at the code. I attached the files as a zip and a screenshot of the interface.

denes.szabo’s picture

I see. I understand it, but I think we should only give an active shortcodes list only to the editors. And we should wrote a separate plugin for the editors. But first I should discover the wysiwyg api module for a clean way to communicate all editors. Not just only one, special editor.

I think, it is a big request, but it would be a nice feature.

First I will make it for the tinymce beacuse I am using it. :)

brenes’s picture

That sounds like a good idea. Please dont't hesitate to contact me if you need my help for testing purpose.

jedihe’s picture

Hi Denes.Szabo,

Probably you want to look at this: http://deglos.com/blog/2010/12/21/building-wysiwyg-plugin-drupal :)

BTW, your module is very nice, thanks for writing it!

jedihe’s picture

-- duplicate

denes.szabo’s picture

Thank you for your link! As I see on a first look, very useful tutorial!

scarmardo’s picture

I would like to convert a basic wordpress shortcode, but need an example of how it would look in the shortcode module.

How would I do this via the shortcode module?

This is what I would do in wordpress:

function shortcode_pullquote_left( $atts, $content = null ) {
   return '<span class="pullquote_left">' . do_shortcode($content) . '</span>';
}
add_shortcode('pullquote_left', 'shortcode_pullquote_left');
denes.szabo’s picture

Hi,

I have made the quote plugin - it is in the shortcode basic tags module. Just enable it!

For all shortcodes I made help. You can see it on the help format section of the textarea. (http://yoursite/filter/tips).
It says:

[quote (class="additional class")]text[/quote] replace a given text formatted like a quote.

Sample css:
.quote { display:block; float:left; width:30%; margin:20px; margin-left:0; padding:5px 0 5px 20px; font-style:italic; border-left:3px solid #E8E8E8; line-heigh:1.5em; font-size:14px; letter-spacing: 1px; word-spacing: 2px; } .quote.right{ float:right; margin-right:0; margin-left:20px; } 

The original wp's shortcode code not proper for us - I just use the "shortcode" idea and my code based on their code, but I quite drupalized it.

If you want any special theming for your quote you just have to only override this function:

function theme_shortcode_quote($text, $class) {                                                                             
  return '<span class="' . $class . '">' . $text . '</span>';                                                               
}

But, I think you have to insert your quote as [quote class="pullquote_left"]My quote[/quote]

The quote markup automatically given the "quote" class.

erjenkins1’s picture

Hello. I'm hoping you can help me. I can't find where to input a new shortcode.

I'm trying to set a shortcode to display an author's specific ad (I do this for different authors).

Here is the code I use in Wordpress

function showads() {
return 'GOOGLE AD CODE HERE';
}

add_shortcode('authorname', 'showads');

Please help!!! This plugin appears to have the capability to do what I need.

denes.szabo’s picture

Please, send me the google code, what should we insert as the ad html - or the google ad docs page.

But, it is easy task, I think.

infomance’s picture

Hello and thank you. How can I send you the code?

denes.szabo’s picture

Contact, issue and I have already sent you a contact message.

Docc’s picture

Status: Active » Closed (fixed)

These are 2 different issues(wysiwyg and shortcode api).

For 6.x you can look into the submodule shortcode_basic_tags on how to use the _shortcodes hook.
D7 version has an API file.

LaurenW’s picture

Can anyone provide more information on how to add additional shortcodes either programmatically or through the Drupal backend? It is not obvious at all for someone who does not develop modules. I really need one for buttons, but it does not seem to be an option when I go through the checkboxes in the text input format although I have Basic Shortcodes Library also installed.

Thanks,
Lauren

memoday’s picture

Issue summary: View changes

Hi @Denes.Szabo

First, thanks for the great module. I am having hard time figuring out how to additional custom shortcodes. I would like to add Google Define to a node. How can I implement that in "shortcode_basic_tags.module"? Thanks in advance for your help!

Zeid

snarf1974’s picture

Hi @Denes.Szabo,

Like @Zeid, I too thank you for a fantastic module.

I was having trouble adding custom shortcodes but stumbled upon this great post by Brianna Deleasa:
https://briannadeleasa.com/blog/drupal-php/shortcodes-drupal-yes-you-can

Followed it step by step, and now have working custom shortcodes. Hope this helps anyone who might be trying to do likewise :)

memoday’s picture

@snarf1974 Thanks a million for sharing this! I appreciate it.

I hope there will be an easier way to add custom shortcodes in the future.

denes.szabo’s picture

Thanks Guys, I just added the link of Brianna Deleasa's tutorial to the project page into the Docs, tutorials section.

digibrill’s picture

denes.szabo’s picture

@digibrill THX! I just updated the module main page with the correct link to this blog post.

siraj j’s picture

Issue summary: View changes
StatusFileSize
new23.09 MB

I want to shortcode my content for the following html page, I installed the shortode contributed module with my drupal8 but I didn't get the page. Please help me

The broken investment value equation

NIIT Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Laboris nisi ut aliquip ex ea commodo consequat. "

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. "

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Only local images are allowed.
denes.szabo’s picture

@Siraj J: It's an old (very old) issue… 6.x, closed.

Please: create new issue, try to explain your problem clearly and easy repeatable manner. I see lot of "Lorem ipsum". This can't help.

What is the your input format config? Which ShortCode macros you enabled. What was the original content before the SC macro, what should be display?