URL customisation rewrite? www.url.co.uk/?brand=branda

Thanks its using PHP

(You'd probably gathered I'm not a coder)

So how does the URL command then talk to the stylesheet to tell it that it wants a different brand logo? does it replace a div name on the page to do this?

Thanks
 
Hi thanks for your help guys sorry for the late reply - on the last reply from Spunkey - where would I reference the location of the logos storred? would I put the full url or dir in the areas you currently have logoa.jpg?
 
Can this method also work to swap a DIV out instead? IE if I have a div that specifies the correct formatting and logo within it - instead of just swapping out the .jpg or .png file can it just replace the div id like

<div id="logo1">
<div id="logo2>

ect?
 
Works a charm thanks Spunkey - whats the cleanest way to put in a default div like the example above with the default $logo
 
How would I do what Jestar suggested but with Div's not direct image links?

I've tried:

<?php

$known_logos = array (
'a' => '<div id="a"></div>',
'b' => '<div id="b"></div>');

$default_logo = 'a';

$logo_to_use = isset($_GET['brand']) && isset($known_logos[$_GET['brand']])
? $known_logos[$_GET['brand']]
: $default_logo;

?>
 
I'm trying to rewrite with the htaccess but not having much luck - not sure if I'm setting my rule backwards or not but either don't seem to work:

I want:

www.example.co.uk/first/second/index.php?brand=a

to rewrite to

www.example.co.uk/first/a/second

so that I can use the neater url to show people the correct page

This is the rule I thought would work:

RewriteEngine on

RewriteRule ^first/a/second$ first/second/index.php?brand=a
 
The rewrite rule doesn't seem to be working either - am I right in thinking that the first part of the rule should be the new pretty link I want and the second part of the rule is the original link?
 
hmm not seeming to have much luck with this .htaccess I've tried it in the sites root as well as in /a/ - do some servers have rules blocking htaccess modifications like this or am I missing something easy?

could I try it with a full url for testing ?
 
The default logo doesn't appear to be displaying (the set ones work fine) - anyway to troubleshoot this? does the echo $logo_to_use; code cover the default logo if its not been specified? it looks like it does but unsure to why it isnt


<?php

$known_logos = array (
'a' => '<div id="a"></div>',
'b' => '<div id="b"></div>');

$default_logo = $default_logos['<div id="a"></div>'];

$logo_to_use = isset($_GET['brand']) && isset($known_logos[$_GET['brand']])
? $known_logos[$_GET['brand']]
: $default_logo;

echo $logo_to_use;
?>
 
perfect I had $known_logos not $default_logos in there at first causing the original problem - thanks for explaining the different code structures - very helpful indeed :)
 
More help - sorry! - I'd like to add another query for eg:

index.php?brand=a&video=blue

I started tweaking the code above but it got me wondering when it comes to the echo to draw the information at the moment it places in brand to use from the list above it..

however from the list above I'd like it to put in quite a chunk of code (a heading, paragraphs, divs, video file). which is specific to the video parameter chosen.

to keep it clean is it best to write a few rules (1 to replace the div heading text) (1 to replace the video variable ie var videoID = 9;) (one to replace the paragraph div with new text) and one to replace a second paragraph div)

Or would it be best to just have all of that code in one big chunk to go in depending on video= option?

I'm not sure how to reference say video=blue and then tell it where the mass of code it to put in as the original code will just place in the name from the array above?

Is that too confusing ?
 
Back
Top Bottom