Main Menu
collapse

Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

User Info

Welcome Guest.
Please log in.

Who's Online

  • Dot Guests: 1274
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]


If you're interested in helping other members with support requests, consider joining the Community Support Helpers group.

Hide Blocks based on URL

Started by pgordemer, September 17, 2012, 09:39:00 PM

Previous topic - Next topic

0 Members and 4 Guests are viewing this topic.

pgordemer

I have 3 domains names that come into the same SMF/Simpleportal site. The forums is the same for all 3 domains, but I would like the frontpage blocks to appear different for each domain. In this case a special HTML welcome block for each domain. Using the custom options, how can I hide a block if the url contains domain1.com but still display if domain2.com or domain3.com is there.

SM 2.02
SP 2.35


pgordemer

I don't mind editing the PHP code directly if someone can give a sub name to take a look at. I can obviously get the url with $_Server[SERVER_NAME]


andershz

How about using a PHP block instead of a HTML block?
In that PHP block you could echo different HTML depending on $_SERVER['SERVER_NAME'].

pgordemer

I am doing that already, I want to be able to do that with Built-in blocks - or any block.

andy

#5
I don't know much about this but maybe a suggestion...

I'm guessing it wouldnt be hard to get the contents of a local file (using php block) without using the full url (including domain name)... just the relative url from root.
If you can do that then each file would have the same name, be in the same relative location in the file system, but have different welcome text for each domain.

Just my guess.


Everyone is a volunteer here so please try and make a small donation to keep the Simple Portal website running


andershz

#6
Quote from: pgordemer on September 29, 2012, 07:55:20 PM
I am doing that already, I want to be able to do that with Built-in blocks - or any block.

Then the scope was a bit bigger than indicated by your original post, but it turns to be fairly easy anyway.
There is an (as far as I can see) undocumented feature that lets you insert arbitrary php code in the "Custom Display Options" field, (visible under " Display Options" if you tick the "Advanced Options" box).
Just start with "$php", then add code that returns true if the block should be shown or false if it shouldn't.
For example, to only show the block on the front page and only if the domain is "domain1.com":
$php return empty($action) && $_SERVER['HTTP_HOST']=='domain1.com'
Don't tick any of the boxes under "Select Actions", "Select Boards" or "Select Pages" since that will override the Custom Display Options.

I can't guarantee that this feature will be available in future versions of the portal, but at least it works in 2.3.5.

EDIT:
Note that this feature uses eval, so there might be some security issues.