• In the interest of not unnecessarily creating additional scripts or potentially introducing incompatible conflicts with built-in scripts, I’m working on trying to find ways to extend or override the templates and functionality created by the built-in [playist] shortcode, and it’s associated Backbone.js based templates/functionality. In doing so, I’ve ran into a couple of problems, most likely due to being unfamiliar with Backbone.

    I’m wanting to be able to create video playlist pages that can utilize the built-in [playlist] shortcode, but split the playing video and the playlist items themselves out into separate elements. I want the videos to remain in the main content area, and the playlist to show in the sidebar, or another defined area. I’ve gotten as far as overriding the shortcode to point to custom script and template definitions, and duplicating the wp-playlist.js file and wp_underscore_playlist_templates function, to at least, initially, modify the layout and data structure, but now, since the playlist is outside of the main Backbone view, I’m running into problems maintaining the functionality of jumping to new videos.

    Has anyone worked with modifying the template files or creating customizations of the default playlist in this way?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi, qco. I’m in a similar situation, but it seems your knowledge is more advanced than mine, I’m a beginner.
    Here is my path:
    ? I copied the entire code of [playlist] shortcode from media.php to a new document, just for creating a new shortcode.
    ? Then I added a couple of lines to remove the “wp_underscore_playlist_templates” and add my own template:

    add_action( 'wp_playlist_scripts', 'my_playlist_script' ); 
    
    function my_playlist_script()
    {
        remove_action( 'wp_footer', 'wp_underscore_playlist_templates', 0 );
        add_action( 'wp_footer', 'my_playlist_buytrack_template', 0 );
    }

    ? As a result, both [playlist] and [my_playlist] uses the same template.
    What I want is to use different templates, not to override the WP default’s.
    Can you give me some guide on this? How do you point to custom template definitions?
    Thanks!

    Thread Starter qco

    (@qco)

    Hi damen02,

    The template scripts are loaded in the wp_footer and admin_footer (if you want to override the admin template as well) actions, loaded through the wp_playlist_scripts action. You can actually override those templates directly:

    remove_action( 'wp_footer', 'wp_underscore_playlist_templates', 0 );
    add_action( 'wp_footer', 'my_underscore_playlist_templates', 0 );

    If it were me, for the sake of removing code repetition, I would probably just add an attribute to the playlist shortcode to define a template, and then override those wp_footer actions based on that attribute ([playlist template="my_template"]), instead of having separate playlist and my_playlist shortcodes.

    FWIW, I was finally able to override these templates for my own needs. My issues were mostly related to just dealing with how the Backbone integration works with everything. I was unfamiliar with Backbone, and after learning more about it, I was able to work through my own specific needs.

    Hi qco, thanks for your quick answer. I’m glad you solved your issue.
    ? You are right, I can take off a couple of lines, dont need the function.
    ? I prefer the [my_shortcode] path and avoided extra arguments due to usability (it could be hundreds of instances).
    ? Plus, a separate shortcode prevents overrides from uptdates.
    However, I accept your suggestion,
    but I still cant understand, How WP knows WHICH template to use?
    I can’t find the lines pointing to the templates.

    Can two templates coexist? One for [playlist] and another for [my_playlist]
    Please, if you can, be obvious, I’m a newbie ??
    Thanks a lot.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Extending or Overriding Playlist Templates’ is closed to new replies.