Forum for discussing general topics related to Couch.
13 posts Page 1 of 2
Hello,
Is it possible to embed souncloud audio into my blog posts using shortcodes just like we can do for youtube, vimeo and the rest?

If yes, how can that be achieved. Thank you
Code: Select all
$FUNCS->register_shortcode( 'soundcloud', 'soundcloud_handler' );
   function soundcloud_handler( $params, $content=null ){
      global $FUNCS;

      extract( $FUNCS->get_named_vars(array(
         'src' => '',
      ), $params) );

   $html =<<<EOS
<iframe width="100%" height="166" scrolling="no" frameborder="no" src="$src"></iframe>
EOS;
 
   return $html
;
   


Please place this in your kfunctions.php file along with other shortcode functions.
Documentation: http://docs.couchcms.com/miscellaneous/shortcodes.html

Usage:
Code: Select all
 [soundcloud src="www.soundcloud.com/your/embed/url"]

Hope it helps.
Image
Not working. The shortcode text rather gets outputted:

Soundcloud.JPG
Soundcloud.JPG (90.54 KiB) Viewed 289 times
Please refer to the documentation on shortcodes:
Wrap the editable in the do_shortcodes tag like so:
Code: Select all
<cms:do_shortcodes><cms:show my_content /></cms:do_shortcodes>
Image
Yes I have that in place and tested it with a youtube shortcode and it worked correctly.
Code: Select all
[youtube video="yUvBBO5wvuY"]
I ws able to implement the soundcloud shortcode so the raw code does not apppear again but then the soundcloud api does not appear at all. When I looked at the source code this is what I saw:
Code: Select all
<iframe width="100%" height="166" scrolling="no" frameborder="no" src=""></iframe>
My apologies, I made a mistake in my original post (Corrected now).

The parameter defining the URL should be "src". As below:

Code: Select all
[soundcloud src="https://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F1848538&show_artwork=true"]
Image
Thank you very much Bartonsweb. It finally worked but I want to know why this code doesn't work.
Code: Select all
<iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/64732777&amp;auto_play=false&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false&amp;visual=true"></iframe>


I copied it from soundcloud's embed. Both the iframe and wordpress code versions do not work
If you want to copy/paste from the "wordpress" embed link, change your kfunctions.php code:

Code: Select all
$FUNCS->register_shortcode( 'soundcloud', 'soundcloud_handler' );
   function soundcloud_handler( $params, $content=null ){
      global $FUNCS;

      extract( $FUNCS->get_named_vars(array(
         'url' => '',
         'height' => '166',
         'width' => '100%',
         'params' => 'color=0066cc',
      ), $params) );
    $src = "$url" . "&amp;" . "$params";
   $html =<<<EOS
<iframe width="$width" height="$height" scrolling="no" frameborder="no" src="$src"></iframe>
EOS;

   return $html;
   }


You can then copy the wordpress short tag from the embed page:
Code: Select all
[soundcloud url="https://api.soundcloud.com/tracks/34019569" params="color=0066cc" width="100%" height="166" iframe="true" /]


Note: This changes the parameter back from "src" to "url", so my last post becomes invalid.
Image
API not showing up on the front-end. When I viewed the page source this was what I saw:
Code: Select all
<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://api.soundcloud.com/tracks/330243250&amp;color=ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false"></iframe>

But nothing appears on the front-end. What could be wrong?
13 posts Page 1 of 2

Who is online

In total there are 5 users online :: 0 registered, 0 hidden and 5 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 5 guests

cron