www.webdeveloper.com
Results 1 to 2 of 2

Thread: Conditional URL

  1. #1
    Join Date
    Oct 2013
    Posts
    4

    Conditional URL

    We currently have a profile page that displays users products purchase on our website. One of the products they can purchase is an on-demand video and along with that video they can download 2 .pdf files. Recently it has come to my attention that they may need to add to one of the files on occasion so they want the user to be able to download the .zip file when there is one available for that product.
    Here is the snippet of code for the button:

    <a href="http://domain name/folder/handbook_<%= displayProductCode %>.pdf" target="_blank"><img src="images/download_handbook_btn.png" alt="Download Handbook" /></a>

    The handbook_<%displayProductCode %> is how every file name will start so if there is a file called handbook_<%displayProductCode %> I need the button to link to that .zip file file. If not then I need it to default to the .pdf.

    Thanks in advance.

    Scott

  2. #2
    Join Date
    Oct 2013
    Location
    Charleston,USA
    Posts
    2
    // Uncomment only when new rewrites have been made
    //add_filter('init', 'wds_flush');

    // Leave uncommented
    add_filter('rewrite_rules_array', 'wds_user_rewrite');
    add_filter('query_vars','wds_query_vars');

    function wds_flush()
    {
    global $wp_rewrite;
    $wp_rewrite->flush_rules();
    }
    function wds_user_rewrite($rules)
    {
    global $wp_rewrite;
    $newRule = array(
    '^~(.+)$' => 'index.php?pagename=user&uid=$matches[1]&act=show',
    );
    $newRules = $newRule + $rules;

    return $newRules;
    }
    function wds_query_vars($vars)
    {
    array_push($vars, 'uid');
    array_push($vars, 'act');

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles