Forum for discussing general topics related to Couch.
12 posts Page 1 of 2
I'm integrating couchcms into a site and within a paragraph of text is a phone number that they would like to be a link like
Code: Select all
<a href="tel:">phone number</a>


I richtext and full toolbar added in the cms backend, is there a way it can be made a link as above within the paragraph of text

I could create a input field for it and then use the cms tags within the a href link as I did that method on another page but think that method it would show at the end of the paragraph and not in amongst it

Hopefully that makes sense, a example of the text paragraph is below

For any issues related to our policies, contact our filtration manager on<a href="tel:00000000000">0000 0000000</a>.
You may try creating a shortcode for it - https://docs.couchcms.com/miscellaneous/shortcodes.html
Thank you KK, I'm just having a look at it now but what if the phone number changes and they want to change it themselves, would I keep having to change it in the kfunctions.php file so it returns the correct phone number?
They'll change the data within the richtext area, like all other data.
The code in kfunctions serves only to format the data and output it as a link.
ahh ok, I'm new to shortcodes, I have so far in the page

Code: Select all
<cms:nl2br><cms:do_shortcodes><cms:show supply_chain_text /></cms:do_shortcodes></cms:nl2br>


then the kfunctions.php page code is below

Code: Select all
<?php
$FUNCS->register_shortcode( 'phonenumber', 'phonenumber_handler' );

function phonenumber_handler( $params, $content=null ){
    return '<a href="tel:[phonenumber]">[phonenumber]</a>';
}
?>


Within the richarea I have put [phonenumber] which outputs the following

Code: Select all
<a href="tel:[phonenumber]">[phonenumber]</a>


That's where I am unsure how to get it to display the phone number, if I change it to [0161 9719041] it does not make it a link and just outputs [0161 9719041] on the frontend
Please see in the docs how we pass parameters to the shortcode - there are several examples in there.
I've had a look at that section in the documentation but not understanding it but will keep trying to work it out
Don't think I am getting it as I read the line [some_shortcode "hello" 'world' hi ] as in my code would be [phonenumber "00000 000000"]

I don't think that's right as it's just outputting
Code: Select all
<a href="tel:phonenumber">phonenumber</a>
in the source code

it's got to be my kfunctions.php file that's wrong

Code: Select all
<?php
$FUNCS->register_shortcode( 'phonenumber', 'phonenumber_handler' );

function phonenumber_handler( $params, $content=null ){
    return '<a href="tel:phonenumber">phonenumber</a>';
}
?>


I'm not really understanding the examples as they are for google maps and iframe videos, I can't see about making links within them examples
I'm sorry but can't work it out on passing parameters etc. I'm guessing it's the kfunctions.php coding that needs to be changed but no idea what to

I have tried to understand it but not getting it
Would I need something like this?

Code: Select all
<?php
$FUNCS->register_shortcode( 'phonenumber', 'phonenumber_handler' );
function phonenumber_handler( $params, $content=null ){
    global $FUNCS, $CTX;
    extract( $FUNCS->get_named_vars(array(
        'number' => ''
    ), $params) )
return '<a href="tel:$content">$content</a>';
};
?>


or more something like this?

Code: Select all
<?php
   // Usage: [phonenumber]00000 000000[/phonenumber]
   $FUNCS->register_shortcode( 'phonenumber', 'phonenumber_handler' );
   function phonenumber_handler( $params, $content=null ){
      global $FUNCS;

      $html = "<a href="tel:='{$content}'" />{$content}</a>";

      return $FUNCS->embed( $html, $is_code=1 );
   }
?>
12 posts Page 1 of 2