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

  • SEARCH
  • Home
  • 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 8250659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:58:07+00:00 2026-06-07T23:58:07+00:00

I am using a theme using sprintf which I am very new to. I

  • 0

I am using a theme using sprintf which I am very new to. I cannot get custom support from the developer on this so I am trying to figure it out on my own.

Not understanding how sprintf works, I’ve Googled loads of pages trying to find a fix to what I thought would have been simple.

The theme uses %s to load a text string, in this case the title of the page. I just want the title to link to the page! That’s it! No less, no more. I was able to come up with something close below:

// Featured columns
case 'columns':
    $count = Website::getThemeOption('front_page/columns/count');
    $classes = array('one', 'two', 'three', 'four');
    $columns = array();
    for ($i = 0; $i < $count; $i++) {
        extract(Website::getThemeOption('front_page/columns/column/'.$i, true)->toArray());
        $text = DroneFunc::stringToHTML($text, false);
        if ($more && $link) {
            $text .= sprintf(' <a href="%s" class="more">%s</a>', $link, $more);
        }
        $columns[] = sprintf(
            '<li class="column">'.
                '<img src="%s/data/img/icons/32/%s" alt="" class="icon">'.
                '<h1><a href="%1$s">%s</a></h1><p>%s</p>'.
            '</li>',
            Website::get('template_uri'), $icon, $title, $text
        );
    }
    ?>
    <section class="columns <?php echo $classes[$count-1]; ?> clear">
        <ul>
            <?php echo implode('', $columns); ?>
        </ul>
    </section>
    <?php
    break;

Now originally, there was no hyperlink reference… I added that in. What this does now is make the h1 title clickable but it just goes to the root of the theme folder, not the title’s page.

Any help in understanding this and making it work would be greatly appreciated.

  • 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-07T23:58:09+00:00Added an answer on June 7, 2026 at 11:58 pm

    Sprintf basix

    Sprintf adds the parameters to the first parameter at the place of the placeholders (which begins with %).

    For instance:

    $name = 'Rob';
    $str = sprintf('Hello, I am %s', $name); // become: Hello, I am Rob
    

    The letter after % is the first letter of the type of the parameter. A string is %s, an decimal is %d. For instance:

    $name = 'Rob';
    $age = 26;
    $str = sprintf('Hello, I am %s and I am %d years old.', $name, $age);
    // become: Hello, I am Rob and I am 26 years old.
    

    Sprintf use the order of the parameters to determine where to place it in the string. The first placeholder gets the second parameter, the second placeholder the thirth, ect.
    If you want to change this, you need to specify this between % and the type. You do this by <place>$ where <place> is the place nummer.

    $name = 'Rob';
    $age = 26;
    $str = sprintf('Hello, I am %2$s and I am %1$d years old.', $age, $name);
    // become: Hello, I am Rob and I am 26 years old.
    

    The answer

    You do this:

    '<h1><a href="%1$s">%s</a></h1><p>%s</p>'
    

    The %1$s is the first parameter, which is the template_uri. I think this isn’t the url which you want to link to? You want to link to the uri in $link. Just place that in the parameters and refer to it:

    sprintf(
        '...'.
        '<h1><a href="%s">%s</a></h1><p>%s</p>',
        Website::get('template_uri'), $icon, $link, $title, $text
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the theme DarkExpression from WPF Futures . It does not seem
I've create a custom theme using Sencha ExtJS and the compass compile and sencha
I am using the WordPress theme Studio8 and I have create some custom forms
When using a Zen sub-theme in Drupal, I get the following warnings. How can
I am using bootstrap with a theme from bootswatch with html5 boiler plate to
I am using drupal 7's premium responsive theme, and I cannot seem to make
I have been trying to do this in ms visual studio 2008 using the
I've been trying to get this code to work for hours! All I need
i am trying to make a custom login form in drupal-6.22 using Email Registration
I am developing a WPF application that must run using Windows Classic theme. The

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.