A programmer friend of mine once said that I will quickly find a limit to my skills and need to make changes directly into the php code, well I’m there on this one, at least I think so...

What I want to do it to display different videos in my theme depending on the webpage. Right now the theme only displays a video in the header section based on whether 'theme_head_use_video' = TRUE, and if so, it displays just one “default video”.

What I wanted to do was to nest another if statement inside the select statement to select from two different videos depending on what page the user is on.

That is to say - to use a default video, except when the user is on a specific page (or URL) using the variable "Machine Name" of that page. Needless to say, I've not worked much using PHP, but for this issue, I desire to modify the existing if statement in the template code directly.

Here is the statement that currently shows one default video:

if ( theme_get_setting( 'theme_head_use_video' ) ) :
youtube
endif;

What would a new "if statement" look like to select either this default video "/my video" or another 2nd video "/my alt video" depending on the specific landing page’s machine name = my_alternative_page ?

Thanks to everyone for their help and advice.

Comments

Jaypan’s picture

It sounds like you want something like this:

 if ( theme_get_setting( 'theme_head_use_video' ) ) : 
  $current_page = current_page();
  if($current_page == '/path/to/some/page')
  {
    // insert video for that page
  }
  else
  {
    // insert video for the rest of the pages
  }
 endif; 
bobby-mc’s picture

Thank you. Brilliant, I will try that.