Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8771439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:47:19+00:00 2026-06-13T17:47:19+00:00

I need to use a string/shortcode in a CMS text area to define a

  • 0

I need to use a string/shortcode in a CMS text area to define a button… something simple for non-technical users like:

[button text=”Click Here” href=”http://www.google.com”%5D

Based on that string, I need to dynamically create a button using mootools (or javascript in general) on the front end (jquery isn’t avaialble in our environment). So far, I haven’t been able to parse code starting with brackets and then grab those attributes for use in code. I will then need to destroy the original shortcode. It doesn’t have to be setup exactly the way I have it above if there is a better way…Any suggestions are appreciated.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:47:20+00:00Added an answer on June 13, 2026 at 5:47 pm

    Here’s the solution I came up… It’s a bit of a hack, but it worked. The CMS that I am working with is Coldfusion-based, but the method should be transferrable…

    Another complexity: In our case, we needed the editable button to appear in a place separate from the editable area of the template. Basically, we had a non-editable button in a sidebar that we wanted to make easily editable from the main content area. So, if the user defines a button, we would replace the sidebar button with a user-defined button. So I have an extra step where I used mootools to grab the button that is created, replace the button in the sidebar on the page and then destroy the original button.

    The goal was for a user to enter a short-code somewhere in a text area in the CMS, something like:

    [button id="override-button" title="XXX" href="YYY"][/button]
    

    The backend would translate this into a DOM element, and the on the front end, we would use mootools to position the button where it needs to be and then destroy the original markup.

    First, I searched for the code in the DB output…

    <cfset find1='\[button'>    <!-- open-->
    <cfset find2='\]\[/button]'>    <!-- close -->
    

    Next, using regular expression replace in coldfusion, I replaced the first instance of the button with the markup… (rs.body refers the body data returned from the database)…

    <cfset replace1 = "<button">
    <cfset replace2 = "></button>">
    <cfset rs.body=#REReplace(rs.body,find1,replace1,"ONE")#>
    <cfset rs.body=#REReplace(rs.body,find2,replace2,"ONE")#>
    

    So, the resulting markup would be:

    <button id="override-button" title="XXX" href="YYY"></button>
    

    Next, I used mootools to manipulate that DOM element. As mentioned, there was already a button in the sidebar with the id “open-form-button,” so this grabs that button and replaces the text and link with the attributes defined above, then destroys the element defined above.

    var overrideBtn = $('override-button');
    var overrideBtn_title,overrideBtn_href = null;
    
    if (overrideBtn) {
    overrideBtn_title = overrideBtn.getProperty('title');
    overrideBtn_href = overrideBtn.getProperty('href');
    
    if (overrideBtn_title && overrideBtn_href)
    {
        $('open-form-button').set('text', overrideBtn_title);
        $('open-form-button').setProperty('href',overrideBtn_href);
        overrideBtn.dispose();
    }
    }
    

    And that’s it. I don’t know how helpful this will be to anyone else, but since Julian suggested I post my solution, I hope it helps someone along the way! Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Ruby you can use string interpolation like so: text = This is visit
I'm using Qt creator 2.4. I need to use a string say hiworld in
I need to get it as a string to use elsewhere in the program,
I need to parse a XML String so I can use some of the
I need a regex to use in Java to replace a String with UNKNOWN
I need to compare hash values of two strings. I use string template for
When I need to join two strings I use String.Format (or StringBuilder if it
I need to use a string as the ID to obtain some object. At
I need to use a string query to make a DB search for a
I need to use some string replacement in Perl to ease translations, i.e. replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.