Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8971145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:53:18+00:00 2026-06-15T17:53:18+00:00

I have two variables, one is $video_id which contains a youtube or vimeo video

  • 0

I have two variables, one is $video_id which contains a youtube or vimeo video id.
The other is $video_type which contains either ‘youtube’ or ‘vimeo’.

I have two functions in php,
youtube_embed($id, $width, $height)
vimeo_embed($id, $width, $height)

What I want to do is call this function passing it in the $video_id

I could do:

{if $video_type == 'youtube'}
    {$video_id|youtube_embed:123:123}
{elseif $video_type == 'vimeo'}
    {$video_id|vimeo_embed:123:123}
{/if}

But I am wondering if you can have variable modifier names, something like

{$video_id|`$video_type`_embed:123:123}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:53:19+00:00Added an answer on June 15, 2026 at 5:53 pm

    That’s a Bad Idea, even if you could.

    Your code would be much clearer to read, maintain and extend in the future if you did:

    {$video_id|video_embed:$video_type:123:123}
    

    and then in PHP check for $video_type and pass it on to the appropriate modifier, rather than trying to handle it at the template level.

    function video_embed($video_id, $video_type, $x, $y){
        switch($video_type){
            case('youtube'):
                youtube_embed($video_id, $x, $y);
                break;
    
            case('vimeo'):
                vimeo_embed($video_id, $x, $y);
                break;
    
            default:
                throw new UnsupportVideoTypeException($video_type);
        }
    }
    

    When you inevitably need to support a new video type you will only have to add some code in the video_embed function in PHP, rather than editing every template that displays a video.

    For the record, no it doesn’t appear possible. Looking at the source code for Smarty it doesn’t try to evaluate variables when it’s expecting a modifier.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two php variables, one integer and other json, which I convert into
I have declared two variables (one global and other local) in a simple C
I have two variables, one is called PaidThisMonth , and the other is called
I have a javascript which takes two variables i.e two lists one is a
I have two php files, one manages database connection and the other retrieves data
Let's say I have these two variables $number = 1; $word = one; and
I have two pages. First one we open with $_POST variables in its url,
I have two variables in my xslt 1.0 template, each one holding a node-set
I have two variables, one with text, and another with patterns. And I want
I have two NSArray variables, each one of then gets a similar NSDictionary inside.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.