Use dynamic URLs to 'activate' extra CSS

Error processing SSI file

Answers

  1. Kylian

    • 2018/12/3

    Use the query string parameters to determine which stylesheet to load.

    Basically, create a general stylesheet that is always loaded, regardless of which theme you are using. Then, put theme-specific rules into separate stylesheets and use PHP if statements to determine what markup to send to load the appropriate page.

    <head>
        <link href="common.css" rel="stylesheet" type="text/css" />
        <link href="<?php echo $_GET["style"] == "iPhone" ? "iPhone" : "normal" ?>.css" rel="stylesheet" type="text/css" />
       ...
    </head>
    

    Note, I use the if-check (the ternary operator ? :) rather than just use the string directly from the query string because I want to have a way of sending a default if the user changes the query string and makes a mistake. If you have multiple themes you want to use, you can set up a switch statement and store the appropriate filename in a variable that you reference in the link tag.

    $stylesheet = "default";
    switch ($_GET["style"]) {
        case "iPhone": $stylesheet = "iPhone";
        case "bigBold": $stylesheet = "bigBold";
    }
    
    <link href="<?php echo $stylesheet; ?>.css" rel="stylesheet" type="text/css" />
    
    How to Use:

    To add this code into your PHP page, place the switch code at the top of the page (or, better yet, in it's own included file.

    Top of the page

    Set up your page like this:

    <?php 
        $stylesheet = "default";
        switch ($_GET["style"]) {
            case "iPhone": $stylesheet = "iPhone";
            case "bigBold": $stylesheet = "bigBold";
        }
    ?>
    <!DOCTYPE html>
    <html>
        <head>
            <link href="common.css" rel="stylesheet" type="text/css" />
            <link href="<?php echo $stylesheet; ?>.css" rel="stylesheet" type="text/css" />
           ...
        </head>
        <body>
            ...
        </body>
    <html>
    

    This code would need to be added to every page where you wanted to use alternate styles, so the better option is to separate this code into a file that can be included on all pages.

    As an included file

    Create a file named stylesheetSelector.php and add this code to it:

    <?php 
        $stylesheet = "default";
        switch ($_GET["style"]) {
            case "iPhone": $stylesheet = "iPhone";
            case "bigBold": $stylesheet = "bigBold";
        }
    ?>
    

    Then, in your PHP page:

    <?php include_once('stylesheetSelector.php'); ?>
    <!DOCTYPE html>
    <html>
        <head>
            <link href="common.css" rel="stylesheet" type="text/css" />
            <link href="<?php echo $stylesheet; ?>.css" rel="stylesheet" type="text/css" />
           ...
        </head>
        <body>
            ...
        </body>
    <html>
    

    Do this on all pages, then, if you ever decide to add additional themes, you can simply add the information to the stylesheetSelector.php file and it will be available on EVERY page that includes it.

    CAVEAT: This needs to be done in a .php file, or your web server needs to use PHP to handle .html files, otherwise you'll see the PHP code in cleartext (it won't be interpreted).

  2. Westin

    • 2018/3/17

    In contrast to static URLs, in which the contents of the Web page do not change unless the changes are coded into the HTML, dynamic URLs are generated from​ 

  3. Dayton

    • 2018/7/16

    Hey all . I am trying to create an item in a SharePoint list with some dynamic content. So when an item is created in a list (customers) with a column (store), i would like to create this item in a subsite which also has a list (ShopCustomers) but depending on the store the item will be created in a diffrent subsite.

  4. Memphis

    • 2017/2/11

    How do you make sure that your URLs are SEO friendly? This detailed guide Specifically, dynamic URLs can hurt your SEO because: Like with dates, URL 

  5. Ayden

    • 2021/6/24

    You could change the CSS stylesheet depending on the querystring yes ... something like this in php :

    if ($_GET['light'] == 'on'){
       echo "<style>something here</style>";
    }else {
       echo "<style>something else</style>";
    }
    

    $_GET['light'] gets the querystring value for light

  6. Chase

    • 2017/3/13

    Dynamic URLs often contain the following characters: ?, &, %, +, =, $, cgi-bin,.cgi. A dynamic URL is the address of a dynamic Web page. Previous article automated merchandising Next article BSI – National Standards Body of the UK

  7. Sawyer

    • 2020/7/31

    For that reason, many website owners prefer to build dynamic websites and have dynamic webpages.

  8. Zayne

    • 2020/12/2

    What I'm trying to do is create Amazon.com item URLs that can be accessed by clicking the Amazon item number (which is already a column in my worksheet for each item in my inventory). e.g. Cell E14 has " 6304696469" in it.

  9. Pablo

    • 2018/8/7

    Responding to the include php file . When you use the include <'stylesheetSelector.php'>, how would you include the path within <>. Since we are using separate file kept on a server, which may not have the file in the same directory ?

    read this link about conditional css stating that it is better to check browser abilities rather than selecting based on browswer. The reason is you won't have to update or change code as browser update abilities.

    http://www.conditional-css.com/

  10. Peter

    • 2020/7/15

    A page that needs to access a database or external file to get information needs to be dynamic. For example, when you visit Google and 

  11. Dervishi

    • 2017/5/11

    A dynamic URL is a page address that results from the search of a database-​driven web site Duration: 3:01 Posted: 15 Jun 2012

  12. Jones

    • 2018/10/30

    Award-Winning Search! See Why US Companies Are Choosing Search Labs. 10 Years of Maximizing Your Search Profits Online. Contact Us Today!

  13. Xavier

    • 2016/11/12

    It remains the same, or static, for every viewer of the site. A dynamic website or dynamic web page contains information that changes, depending 

  14. Dallas

    • 2019/3/27

    Contact form 7 Redirecting to Another URL After Submissions 2017 Updates. First you need to update contact form 7 on new version i try it on v7.4.9 and then place a contact form short code in any page and place this JS script any where on page and change url where need to redirect your page after submission

  15. Cristian

    • 2019/5/10

    users will be able to RSVP to event, fill out surveys, respond to comments and browse images, all directly from within an email.

  16. Maxim

    • 2018/4/9

    To accomplish this, you need to first create a text document called ".htaccess" to contain your rules. It must be named exactly that (not 

  17. Nolan

    • 2015/4/6

    Website designers use HTML coding for their websites and usual choice is an HTML template but what they miss out on is the fact that more dynamic their website gets, more is the number of repeat traffic.Thus, high is the SEO rank.HTML templates are easy to install and with simpler coding but PHP templates are comparatively flexible.

  18. Heath

    • 2021/3/9

    Posted: 18 Feb 2017

  19. Robert

    • 2015/2/13

    Yes, you can make dynamic website with joomla. Cheap webhosting @ sinpz.com. google is a website, you can accses most websites by a web browser, so the answer to you question is yes!

  20. Emanuel

    • 2018/12/17

    First, let's clarify what we're talking about: What is a static URL? A static URL is one that does not change, so it typically does not contain any url 

  21. Bruno

    • 2019/7/29

    1. empty your Seo router Setting.configuration ---> Basic setting ---> Frontend ---> Seo / router Setting. 2. Select Product / Article which you want to change URL. Listing is available for all the products / articles. you can search product / Article using search box. 3. You can easily Rewrite Your Article URLs to Make Them SEO Friendly. 4.

  22. Rizzi

    • 2016/7/25

  23. Gray

    • 2018/5/30

    URLs are classified into two types: static and dynamic. A static URL is one in which the content of the web page remains the same as long as the changes are not hard coded within the HTML. On the other hand, a dynamic URL is one which is a result of a search within a website driven by a database running on some script.

  24. Deandre

    • 2017/10/16

    A little help would be a great help! UPDATE <ul> <?php $rec = mysqli_query($​con,"select * from category 

  25. Ayden

    • 2021/3/21

    Super-practical PHP: Learn, by example, how to build a smart website with cookies, sessions, login authentication, MySQL integration, Object Oriented PHP and lots more! Let's parse that. This course is super-practical: packed with knowledge you can put to use right away, while still giving you a good foundational understanding of web

  26. Harley

    • 2019/9/23

    Dynamic URLs or dynamic sites are generated at the moment a user submits a search query. Unlike static websites, they are not stored as a whole on the 

  27. Uriel

    • 2017/9/28

    I recently read jennita's excellent post, "URL Rewrites and 301 Redirects - How does it all work?", and thought a mod_rewrite example might be helpful to some. So, here's some example code of how I have used mod_rewrite to replace dynamic URLs with SEO friendly URLs.

  28. Brett

    • 2019/3/31

    15 Jun 2012

  29. Kieran

    • 2020/10/9

    are called dynamic URLs. It's dynamic because the page is normally generated by using data from a database. The part after "?" is database row identifier which is used to retrieved the specified data from one or more database tables.

  30. Abdiel

    • 2015/4/2

    Is Google a dynamic website?

  31. Finnegan

    • 2015/11/15

    Dynamic URL. It is an address/URL of a Web page with content that depends on variable parameters that provided to the server that delivers it.

  32. Eden

    • 2021/6/11

    example of static website and dynamic website Static website has webpages with constant or fixed content which cannot be changed by the user who visits the site. Static webpages are built using the HTML code and the content is static, meaning it doesn’t change automatically until and unless the webmaster or developer makes changes.

  33. Ramos

    • 2019/11/27

    7 Mar 2020

  34. Braydon

    • 2015/11/26

    Web.Contents with dynamic file URL ‎02-11-2020 02:11 AM I have searched through the community and found out about the limitation of Web.Contents on Power BI Service.

  35. Flores

    • 2018/3/23

    html”. Some typical examples of static URLs are: About us page – http://www.​example.com/about-us.hml; Contact 

  36. Greco

    • 2020/12/28

    Everything that seemed to vanish got sucked up by the more options fly-out menu. This example of dynamic web design keeps the focus on the food and ordering the food, which is what the main focus of this site should be on. W3 SCHOOLS. The site for W3 Schools is immediately apparent as a site for learning web coding languages.

  37. Marcelo

    • 2019/5/19

    Hosting static assets for a dynamic website. You can use Cloud Storage to host static assets for a dynamic website that is hosted, for example, in Google App 

  38. Lucas

    • 2021/8/27

    Let's see why you should avoid dynamic URLs and how to replace them with In this case, such a web page acts just like a template for the content. good reasons why static URLs are better for SEO than dynamic URLs.

  39. Jesse

    • 2020/10/24

    Add a custom "Single Line of Text" field with "URL" format on your form. Create a custom workflow and enable the "Start when record is created". Add a step to update created field value with "Record URL (Dynamic)".

Comments are closed.

More Posts