silverstripe / silverstripe-cms

Silverstripe CMS - this is a module for Silverstripe Framework rather than a standalone app. Use https://github.com/silverstripe/silverstripe-installer/ to set this up.
http://silverstripe.org/
BSD 3-Clause "New" or "Revised" License
515 stars 333 forks source link

Embedding videos is failing #698

Closed sewid closed 11 years ago

sewid commented 11 years ago

When I insert a video using the media button, the video preview is shown in the Html editor. After saving, the page in the frontend shows only:

[embed width=600 height=337 class=left thumbnail=http://b.vimeocdn.com/ts/431/936/431936908_1280.jpg?r=69664]http://vimeo.com/61995717[/embed]

No preview image - no video.

Best regards, sewid

bildschirmfoto 2013-05-08 um 06 51 44 bildschirmfoto 2013-05-08 um 06 51 40

howardgrigg commented 11 years ago

@sewid I'm not reproducing this on 3.1 - are you using $Content.Raw in your template?

sewid commented 11 years ago

@howardgrigg No, I am using $Content in my Layout:

Page.ss (Template)

<div>
  $Layout
</div>

Page.ss (Layout)

<div class="row-fluid">
  <div class="span12">
    <h2>$Title</h2>
    $Content
    $Form
  </div>
</div>

I just tried it with $Content.Raw - no difference.

Additional info: I am using SilverStripe 3.1 Beta 3

sewid commented 11 years ago

Another additional info, when viewing the HTML code int he HTML editor, I get:

<p><img class="left ss-htmleditorfield-file embed" src="http://b.vimeocdn.com/ts/431/936/431936908_1280.jpg?r" width="600" height="337" data-url="http://vimeo.com/61995717" data-width="600" data-height="337" data-class="left" data-thumbnail="http://b.vimeocdn.com/ts/431/936/431936908_1280.jpg?r" data-cssclass="left" /></p>
howardgrigg commented 11 years ago

Yea it's just the shortcode not getting parsed in the template - try adding a link in the content to internal page and see if that displays correctly.

sewid commented 11 years ago

No, it's not working. Generated HTML is:

<p><a href="[sitetree_link,id=3]">Test</a></p>
chillu commented 11 years ago

Hmm that's strange - do you have anything special in you Page or Page_Controller class, like $casting, renderWith() calls or an overloaded Layout()/Content() getter?

sewid commented 11 years ago

Hi, I don't think so, this is my Page.php

<?php
class Page extends SiteTree {

  private static $db = array(
    'RightSidebar' => 'HTMLText',
    'LeftSidebar' => 'HTMLText'
  );

  private static $has_one = array(
  );

  public function BootstrapLinkingMode() {
    if ( $this->isSection() ) {
      return 'active';
    } elseif ( $this->isSection() ) {
      return 'section';
    } else {
      return 'link';
    }
  }

  public function getCMSFields() {
    // Get the fields from the parent implementation
    $fields = parent::getCMSFields();

    $fields->addFieldToTab( 'Root.Sidebars', new HTMLEditorField( 'RightSidebar' ) );
    $fields->addFieldToTab( 'Root.Sidebars', new HTMLEditorField( 'LeftSidebar' ) );

    return $fields;
  }
}
class Page_Controller extends ContentController {

  /**
   * An array of actions that can be accessed via a request. Each array element should be an action name, and the
   * permissions or conditions required to allow the user to access it.
   *
   * <code>
   * array (
   *     'action', // anyone can access this action
   *     'action' => true, // same as above
   *     'action' => 'ADMIN', // you must have ADMIN permissions to access this action
   *     'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
   * );
   * </code>
   *
   * @var array
   */
  // private static $allowed_actions = array( 'doSearch', 'search' );
  private static $allowed_actions = array( 'doSearch' );

  public function init() {
    parent::init();

    // Note: you should use SS template require tags inside your templates
    // instead of putting Requirements calls here.  However these are
    // included so that our older themes still work
    Requirements::themedCSS( 'reset' );
    Requirements::themedCSS( 'layout' );
    Requirements::themedCSS( 'typography' );
    Requirements::themedCSS( 'form' );
  }

  public function ContentWidth() {
    $page = $this->Page( $this->Link() );

    if (!$page) return "span12";

    if ( $page->ClassName == "HomePage" )
      return "span6";

    if ( ( count( $this->getMenu( 2 ) ) || $page->LeftSidebar != "" ) && ( $page->RightSidebar != "" ) ) {
      return "span6";
    } elseif ( count( $this->getMenu( 2 ) ) || $page->LeftSidebar != "" || $page->RightSidebar != "" ) {
      return "span9";
    } else {
      return "span12";
    }
  }

  public function search() {
    if ( $this->request && $this->request->requestVar( 'Search' ) ) {
      $searchText = $this->request->requestVar( 'Search' );
    }else {
      $searchText = '';
    }

    $searchField = new TextField( 'Search', false, $searchText );
    $searchField->addExtraClass( "search-query" );
    $searchField->setAttribute( "placeholder", "Suche" );

    $fields = new FieldList(
      $searchField
    );

    $actions = new FieldList(
      //new FormAction( 'doSearch', 'Go' )
      // new FormAction( 'doSearch' )
    );

    $form = new Form(
      $this,
      'search',
      $fields,
      $actions
    );
    $form->addExtraClass( "navbar-search pull-right" );
    $form->setFormAction( 'home/doSearch' );
    $form->disableSecurityToken();
    $form->setFormMethod( 'GET' );
    $form->setTemplate( 'NavbarSearchForm' );

    return $form;
  }

  //, $form
  public function doSearch( $data ) {
    //Debug::show($data['Search']);
    $start = ( $this->request->getVar( 'start' ) ) ? (int)$this->request->getVar( 'start' ) : 0;
    $escaped_query = Convert::raw2sql( $data['Search'] );
    $query = $data['Search'];
    $limit = 10;

    // $pages = DataObject::get( "Page", "MATCH (Title, Content, RightSidebar, LeftSidebar) AGAINST ('{$escaped_query}' IN BOOLEAN MODE) AND ShowInSearch <> 0" );

    $pages = Page::get()->where( "MATCH (Title, Content, RightSidebar, LeftSidebar) AGAINST ('{$escaped_query}' IN BOOLEAN MODE) AND ShowInSearch <> 0" );
    $twoColumnPages = TwoColumnPage::get()->where( "MATCH (LeftColumn, RightColumn) AGAINST ('{$escaped_query}' IN BOOLEAN MODE) AND ShowInSearch <> 0" );

    $list = new ArrayList;
    foreach ( $pages as $obj ) $list->push( $obj );
    foreach ( $twoColumnPages as $obj ) $list->push( $obj );

    $records = new PaginatedList( $list, $this->request );
    $records->setPageStart( $start );
    $records->setPageLength( $limit );
    $records->setTotalItems( $pages->Count() );

    return $this->customise( array( 'Results' => $records, 'Query' => $query ) )->renderWith( array( 'Page_results', 'Page' ) );
  }

}

Update: I tried to comment all my custom code in Page.php - nothing changed, still the same problem.

chillu commented 11 years ago

Can you please try on a completely new SS installation, ideally the latest 3.1 development branch?

sewid commented 11 years ago

I'll give it a try...

sewid commented 11 years ago

A plain 3.1 dev version is working. So I updated my faulty 3.1 beta 3 to the dev version and now it's working.

I would say, issue can be closed.