Socialengine Tutorial – Disable default css from being loaded

I’ve been working on creating a custom homepage which uses twitter bootstrap however I’ve found the default css being generated by the socialengine is interferring with the bootstrap css.

In order to stop socialengine from adding in the default theme css files head to

Application > Modules > Core > Layouts > Scripts > default-simple.tpl

This default simple is what is loaded on every page and then injected with the page’s content. However I didn’t want any of that to load on my landing page so I’ve done the following;

(In this file look for line 75 where the ‘linking’ of css files begins and I’ve wrapped it in an if statement which says if the current url string == the default home page (e.g. /) then don’t bother loading the rest of the php)

<?php // LINK/STYLES ?>
  <?php
  $uri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
  if(trim($uri, '/') !=  trim($this->baseUrl(), '/')):
  ?>
  <?php
    $this->headLink(array(
      'rel' => 'favicon',
      'href' => ( isset($this->layout()->favicon)
        ? $this->baseUrl() . $this->layout()->favicon
        : '/favicon.ico' ),
      'type' => 'image/x-icon'),
      'PREPEND');
    $themes = array();
    if( !empty($this->layout()->themes) ) {
      $themes = $this->layout()->themes;
    } else {
      $themes = array('default');
    }
    foreach( $themes as $theme ) {
      $this->headLink()
        ->prependStylesheet($this->baseUrl().'/application/css.php?request=application/themes/'.$theme.'/theme.css');
    }
    // Process
    foreach( $this->headLink()->getContainer() as $dat ) {
      if( !empty($dat->href) ) {
        if( false === strpos($dat->href, '?') ) {
          $dat->href .= '?c=' . $counter;
        } else {
          $dat->href .= '&c=' . $counter;
        }
      }
    }
  ?>
 
  <?php endif; ?>

Hope this helps 🙂

PHP – Extract youtube id from youtube url / link

Today I wanted to be able to extract the youtube unique id for the video so that I could automatically embed any youtube video in my webpage.

What I wanted to be able to do was let the user copy + paste in a youtube url such as http://www.youtube.com/watch?v=pJf6S8FYTUo&feature=related and extract the value of the key ‘v’ which is obviously the video id.

After a short while I ran into a stackoverflow question which had an awesomely simple answer;

<?php
$url = "http://www.youtube.com/watch?v=C4kxS1ksqtw&feature=relate";
parse_str( parse_url( $url, PHP_URL_QUERY ), $my_array_of_vars );
echo $my_array_of_vars['v'];    
  // Output: C4kxS1ksqtw
?>

So what this means is that I can now just do the following to embed any youtube video in to a page;

<?php 
$url = "http://www.youtube.com/watch?v=C4kxS1ksqtw&amp;feature=relate"; 
parse_str( parse_url( $url, PHP_URL_QUERY ), $my_array_of_vars ); 
?> 
<i frame src="http://www.youtube.com/embed/<?php echo $my_array_of_vars['v']; ?>" frameborder="0" width="560" height="315">
</i frame>

*remove space between i frame (was to stop it from showing in the post)