Domain Manage

different sidebar to what domain is in the URL

Discussion in 'Wordpress' started by SecNam, Jun 18, 2015.

Thread Status:
Not open for further replies.
  1. SecNam

    SecNam Moderator Staff Member

    Joined:
    Jul 2004
    Posts:
    5,127
    Likes Received:
    37
    Hi

    Can anyone think of an idea or way where i park say 50 domains on a wordpress site i can show a different sidebar to what domain name is in the URL?

    thanks in advance

    paul
     
  2. Domain Forum

    Acorn Domains Elite Member

    Joined:
    1999
    Messages:
    Many
    Likes Received:
    Lots
     
  3. alex

    alex Active Member

    Joined:
    Sep 2007
    Posts:
    769
    Likes Received:
    21
    How is the domain provided in the URL? Is it a parameter such as www.example.com/d=domainname.co.uk
     
  4. SecNam

    SecNam Moderator Staff Member

    Joined:
    Jul 2004
    Posts:
    5,127
    Likes Received:
    37
    hi alex

    i have just added them in cpanel and parked them on the main domain.
     
  5. tifosi United Kingdom

    tifosi Well-Known Member

    Joined:
    Oct 2004
    Posts:
    3,128
    Likes Received:
    45
    Themes call get_sidebar() which loads sidebar.php, which then loads the widgets assigned to the sidebar through the dynamic_sidebar('widget-area') function. Each widget area is defined in the theme functions.php file.

    Different ways to approach it:

    50 sidebar files e.g. sidebar-domain1.php and change the get_sidebar() call to get_sidebar(domain-1) - through capturing the domain via the url, and then widgets assigned to the sidebar in WP admin. Long winded, same widgets.

    One sidebar and register a widget area per domain via register_sidebar() in your functions.php file. Messy.

    One alternative is to bypass widgets and keep the get_sidebar() call, but in the sidebar use an include file with html / php to created the content e.g. include( 'domain1.php') depending on the domain in the url.

    This could be enhanced by creating a post-type called domain and then creating a single-domain.php template file which could be used to select an include file. e.g. /domain/domain1

    You could do it via a taxonomy as well, and capture the term for the include. The file you would use would be taxonomy-domain.php

    The Woosidebars plugin can automate a bit of it if you want the multiple widget areas route. Create a domain taxonomy and a term for each domain and then create a 'new' widget area per term and override the default sidebar. Still messy, you'd end up with a sidebar area per domain in the WP admin area. Still, workable.
    S
     
    Last edited: Jun 18, 2015
  6. alex

    alex Active Member

    Joined:
    Sep 2007
    Posts:
    769
    Likes Received:
    21
    It is my understanding that WordPress requires an install for each domain because of the way the URL structure works. Wouldn't most people therefore use WordPress multi site with a single theme and point the parked domains at the sub-sites? You could then set up the individual sidebars.

    tifosi's suggestions are correct, but assume any single install can handle the multiple domains. If I am correct in thinking you can't then the options are to either go down the multi site route, or have a single central domain with the other domains set as parameters. You can then use that parameter to select the relevent registered sidebar. Parameters themselves are not SEO friendlt, but then again neither is a single page site.
     
  7. tifosi United Kingdom

    tifosi Well-Known Member

    Joined:
    Oct 2004
    Posts:
    3,128
    Likes Received:
    45
    If all you're wanting to change is the sidebar content then multi-site approach is a bit of overkill.

    WP is pretty good at grabbing query vars, though you'd have to register a new one for 'd'. You can then do what you want with it. Using a registered taxonomy and grabbing the term would bypass that, and you'd be easily able to permalink it.
     
  8. alex

    alex Active Member

    Joined:
    Sep 2007
    Posts:
    769
    Likes Received:
    21
    I appreciate that, and agree with you.

    My query is whether say www.example.com and www.example2.com and www.example3.com etc rendering the same WP install will actually work which is what I think the OP is after?
     
    Last edited: Jun 18, 2015
  9. Retired_Member42

    Retired_Member42 Retired Member

    Joined:
    Sep 2009
    Posts:
    1,223
    Likes Received:
    24
    It'd be much easier to advise on the best solution for doing this if we knew what the sidebar contained and how much it differed site to site.
     
  10. tifosi United Kingdom

    tifosi Well-Known Member

    Joined:
    Oct 2004
    Posts:
    3,128
    Likes Received:
    45
    Damn, where's the like button! ;)
     
  11. SecNam

    SecNam Moderator Staff Member

    Joined:
    Jul 2004
    Posts:
    5,127
    Likes Received:
    37
    sorry i should explain more what i am doing, basically i want to park my domains on 1 WP domain and then use different sidebar with products/banners then have a form on the page so basically just trying to monetise my parked domains better.
     
  12. tifosi United Kingdom

    tifosi Well-Known Member

    Joined:
    Oct 2004
    Posts:
    3,128
    Likes Received:
    45
    Might be better to do it by category then.

    Post Type: Domain
    Taxonomy: Category

    Add domain to post type, assign to category. Use woosidebars to generate a 'category' sidebar per category and assign to category term and override the default sidebar. 10+ category sidebars with their own widgets e.g text widgets with products. Should work.
     
  13. alex

    alex Active Member

    Joined:
    Sep 2007
    Posts:
    769
    Likes Received:
    21
    Probably a better question for Paul, but am I missing something?

    Let's say he has example.com, example.org and example.co.uk. If he wants people to go to either of these domains and the page rendered is the homepage for that domain, ie that domain is exactly what is in the address bar, then how can this be done with 1 WordPress install? A single WP install can only work with a single domain. Changing the domain breaks the WP structure.

    I hope I'm wrong mind, because this would seriously help us with a project we're working on at the minute ;)

    But what you suggest tifosi, in my mind, only works if the original domain forwards to a single central domain with the WP install. Now this could be what Paul wants and I've misunderstood, but my impression was that the domain wouldn't forward, it would instead render the instance of WP as its own site defined by the fact the domain doesn't change in any way.

    I can only see this working as either some parameter or sub directory that defines the domain following a redirect, or by multisite where one WP install allows multiple domains to render on a single install.
     
    Last edited: Jun 18, 2015
  14. Retired_member41

    Retired_member41 Retired Member

    Joined:
    Mar 2010
    Posts:
    3,443
    Likes Received:
    55
    There are a load of $10 scripts that allow one Wordpress install to show the parked domains and in the url bar. Don't you just then have some html in the sidebar which displays your products based upon the url?

    If host equals etc your keyword. A couple of lines could work for dozens of domains and different keywords products etc

    Or is that too easy?
     
  15. SecNam

    SecNam Moderator Staff Member

    Joined:
    Jul 2004
    Posts:
    5,127
    Likes Received:
    37
    No its not that easy.
     
  16. SecNam

    SecNam Moderator Staff Member

    Joined:
    Jul 2004
    Posts:
    5,127
    Likes Received:
    37
    What i am after is each domain will stay in the URL i have all that working but what i then want to be able to do is display different sidebars or footer bars which will have php in them to pull products from a database.

    I will reply to your PM
     
  17. AssetDomains United Kingdom

    AssetDomains Well-Known Member

    Joined:
    Feb 2010
    Posts:
    2,953
    Likes Received:
    52
    Do you actually need different sidebars or just the sidebar to display different content.

    Code:
     
    function check_input($data)
    {
        $data = htmlspecialchars($data);
        return $data;
    }
    //Get Page URL
    function curPageURL() {
     $pageURL = 'http';
     if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
     $pageURL .= "://";
     if ($_SERVER["SERVER_PORT"] != "80") {
      $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
     } else {
      $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
     }
     return check_input($pageURL);
    }
    $url = curPageURL();
    $url = str_replace('http://www.','', $url);
    $url = str_replace('/','', $url);
     
     
    
    If you make URL table with all the urls, category, keyword sidebarname etc in your database you could add pull a sidebar based on info stored in the table
    But do you really want to have tons of sidebars I'd just have a url table with the data

    Then in my sidebar code select from url tbles where url = $url get the category keyword or whatever then populate you products based on this
     
Thread Status:
Not open for further replies.

Share This Page