close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Displaying unique StoreMessage div for each vendor

Thread began 1/25/2010 4:42 pm by iggymak198560 | Last modified 2/09/2010 4:55 am by iggymak198560 | 3602 views | 15 replies |

iggymak198560

Displaying unique StoreMessage div for each vendor

Hi guys,

My erstwhile client wants to display a unique image for each vendor in the storeMessage panel/div up top.

I have already made a storeMessage2 attribute in the Common and Home CSS, which works well on all but the home page as I initially wanted, but the vendor's wish comes first, so...

How would one go about making it display subsequent storeMessages... 3, 4, 5, etc by knowing which vendor the user clicked on?

Yikes!

Iggy

Sign in to reply to this post

Dani Chankhour

I'm guessing you already have a way to figure out the vendor. In this case you can just add conditional statement. The Store Message is done by using a CSS background image:

<div id="storeMessage">
<h1>Your Store Message Goes Here!</h1>
</div>

So you can achieve this by adding an inline styling to the storeMessage div as follow:

<?php
$vendor = "one";
if($vendor == "one") {
$image = "Images/boxshots.png";
}else if($vendor == "two") {
$image = "Images/body_bg.png";
}
?>
<div id="storeMessage" style="background-image:url(<?php echo $image; ?>)">
<h1>Your Store Message Goes Here!</h1>
</div>

Sign in to reply to this post

iggymak198560

Fabulous!

Thanks Dani... that's great... and easy, too!

Actually I'll be using the Categories as the "vendor" (as each vendor has 2 or 3 categories for their product lines) so I'll just need to transpose that in your solution.

Oh, the database assigned a number to each CategoryID, so I think it'd be something like...

<?php
$CategoryID = "24";
if($CategoryID == "24") {
$image = "Images/boxshots.png";
}else if($CategoryID == "9") {
$image = "Images/body_bg.png";
}else if($CategoryID == "6") {
$image = "Images/bgthree.png";
}
etcetera...
?>

Does that look right?

Be well!
Iggy

Sign in to reply to this post

Dani Chankhour

That looks correct.

Let me know if you run to any issues.

Sign in to reply to this post

iggymak198560

Great!

Thanks again... be well...

Sign in to reply to this post

iggymak198560

Dani, ran into a big issue with this!

Hi Dani,

The client just decided on which pictures that I Photoshopped go where, and I put in the code below, but it's not working as planned.

The problem is; while the home page is displaying its unique picture, ALL of the other pages, whether a category page, like Products_Results.php?Search=true&CategoryID=5, or a product page like Products_Detail.php?ProductID=205 or one that isn't associated with a category or product such as Support.php; are all exclusively showing the image listed first in the below code as CategoryID 1.

Here's what I put in for code:

<?php
$CategoryID = "1";
if($CategoryID == "1") {
$image = "Images/hkgirlndogbg.jpg";
}else if($CategoryID == "3") {
$image = "Images/2dogsandacatnewwysong.jpg";
}else if($CategoryID == "5") {
$image = "Images/storeMessage_bgboydog.jpg";
}else if($CategoryID == "7") {
$image = "Images/storeMessage_bgtruelove.jpg";
}else if($CategoryID == "9") {
$image = "Images/runningdogbg.jpg";
}else if($CategoryID == "13") {
$image = "Images/girlndogbg1.jpg";
}else if($CategoryID == "15") {
$image = "Images/hkgirlndogbg.jpg";
}else if($CategoryID == "16") {
$image = "Images/hkgirlndogbg.jpg";
}else if($CategoryID == "17") {
$image = "Images/girlndogbg1.jpg";
}else if($CategoryID == "18") {
$image = "Images/girlndogbg1.jpg";
}else if($CategoryID == "19") {
$image = "Images/2dogsandacatnewwysong.jpg";
}else if($CategoryID == "20") {
$image = "Images/2dogsandacatnewwysong.jpg";
}else if($CategoryID == "21") {
$image = "Images/storeMessage_bgboydog.jpg";
}else if($CategoryID == "22") {
$image = "Images/storeMessage_bgboydog.jpg";
}else if($CategoryID == "24") {
$image = "Images/storeMessage_bgtruelove.jpg";
}else if($CategoryID == "25") {
$image = "Images/runningdogbg.jpg";
}
?>
<div id="storeMessage" style="background-image:url(<?php echo $image; ?>)">
<h1>Your Store Message Goes Here!</h1>
</div>

- - - - - - - - -

Here's the source code for the support.php page off of Dreamweaver:

<div id="topNavigation">
<div id="searchBox">
<form id="searchForm" method="get" action="Products_Results.php" >
<input name="Search" type="submit" value="Search" id="Search" alt="Search" />
<input type="text" name="S_ProductName" id="S_ProductName" />
</form>
</div>
<?php require_once("CSSMenuWriter/cssmw_home/menu.php"); ?>
</div>
</div>
<?php
$CategoryID = "1";
if($CategoryID == "1") {
$image = "Images/hkgirlndogbg.jpg";
}else if($CategoryID == "3") {
$image = "Images/2dogsandacatnewwysong.jpg";
}else if($CategoryID == "5") {
$image = "Images/storeMessage_bgboydog.jpg";
}else if($CategoryID == "7") {
$image = "Images/storeMessage_bgtruelove.jpg";
}else if($CategoryID == "9") {
$image = "Images/runningdogbg.jpg";
}else if($CategoryID == "13") {
$image = "Images/girlndogbg1.jpg";
}else if($CategoryID == "15") {
$image = "Images/hkgirlndogbg.jpg";
}else if($CategoryID == "16") {
$image = "Images/hkgirlndogbg.jpg";
}else if($CategoryID == "17") {
$image = "Images/girlndogbg1.jpg";
}else if($CategoryID == "18") {
$image = "Images/girlndogbg1.jpg";
}else if($CategoryID == "19") {
$image = "Images/2dogsandacatnewwysong.jpg";
}else if($CategoryID == "20") {
$image = "Images/2dogsandacatnewwysong.jpg";
}else if($CategoryID == "21") {
$image = "Images/storeMessage_bgboydog.jpg";
}else if($CategoryID == "22") {
$image = "Images/storeMessage_bgboydog.jpg";
}else if($CategoryID == "24") {
$image = "Images/storeMessage_bgtruelove.jpg";
}else if($CategoryID == "25") {
$image = "Images/runningdogbg.jpg";
}
?>
<div id="storeMessage2" style="background-image:url(<?php echo $image; ?>)">
<h1><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<h1><span class="style8"><br />
<br />
<br />
&nbsp; &nbsp;<span class="style16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="style20">The Natural Path to Better Pet Health</span></span></span></h1></h1>
</div>

- - - - - - - - -

And here is the source code for the Support.php page off the browser view:

</div>
</div>
<div id="storeMessage2" style="background-image:url(Images/hkgirlndogbg.jpg)">
<h1><br />
<br />
<br />
<br />
<br />
<br />

<br />
<br />
<br />
<br />
<h1><span class="style8"><br />
<br />
<br />
&nbsp; &nbsp;<span class="style16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="style20">The Natural Path to Better Pet Health</span></span></span></h1></h1>

</div>

- - - - - - - -

The code on the browser looks the same as above for Products_Results.php?Search=true&CategoryID=5 and all the others.

You'll note it says storeMessage2... I made that so that the home page would use it's picture and all the others would display a different one, (that was before the vendor idea and worked well)

But now... I don't know what to do... it's obviously not recognizing the CategryIDs... should I use ProductIDs (There are 80!)? But then what about pages like the About and Support, which should show the home page pic...?

Is there a clever way to write this all into the PHP using the "else if" command so it responds properly, hopefully using only one storeMessage type? Should I release About and Support and the other non-vendor category pages from the template? Would rather not, really... and getting anxious, as...

...we're getting real close to needing to be live too... couple of weeks max... I wish you could see it!

If you need more code let me know!

Thanks!

Iggy

Sign in to reply to this post

Dani Chankhour

Well, if you look at the PHP code you have on your page, you could see that you set the category id to "1", so it make sense that the page is loading the first image, but it is always going to be true. The question here is how do you determine the Category ID, are you sending in the URL:

Produ...e&CategoryID=5

If so you would want to do this:

$CategoryID = $_GET['CategoryID'];

And you would need to update all the links in PowerStore to add a Category ID.

If you could please explain a little more about how you are determining what is the Category ID that you are going to use, i should be able to help you.

Sign in to reply to this post

iggymak198560

How I came up with that code

Originally Said By: Dani Chankhour
  Well, if you look at the PHP code you have on your page, you could see that you set the category id to "1", so it make sense that the page is loading the first image, but it is always going to be true. The question here is how do you determine the Category ID, are you sending in the URL:

Produ...e&CategoryID=5

If so you would want to do this:

$CategoryID = $_GET['CategoryID'];

And you would need to update all the links in PowerStore to add a Category ID.

If you could please explain a little more about how you are determining what is the Category ID that you are going to use, i should be able to help you.  



Thanks, that makes sense to me... for the Category IDs, I just used the number that had been assigned to each of them in the database category table, which resulted in my code.

So I'm thinking from what you said that if I were to add the line you wrote $CategoryID = $_GET['CategoryID']; ... replacing the line I have that says Category = 1

it would probably work right off for a main product category page like Products_Results.php?Search=true&CategoryID=5

but as you suggest I'd need to modify a product specific page's URL like Products_Detail.php?ProductID=205... I'm not sure where exactly to put it in the path, though.

Maybe Products_Detail.php?CategoryID=5&ProductID=205 ? Might that work? Ah! I just popped that URL into the browser and it worked! Yay!

Thanks, I'll report back on that...

But, and this might be a sticky bit, as we also need to have the non-product pages (About, Support, Careers, etc.) show the image from the home page, and I'm not sure how to accomplish that, as they're not associated with a product category and the instructions are making it find categories... maybe there's the "else if" equivalent of a "null" or "none" for those pages?

Sign in to reply to this post

iggymak198560

quick update (a bit too quick)

I changed it to:

<?php
$CategoryID = $_GET['CategoryID'];
if($CategoryID == "1") {
$image = "Images/hkgirlndogbg.jpg";
}else if($CategoryID == "3") {
$image = "Images/2dogsandacatnewwysong.jpg";
}else if($CategoryID == "5") {
$image = "Images/storeMessage_bgboydog.jpg";
}else if($CategoryID == "7") {
$image = "Images/storeMessage_bgtruelove.jpg";
}else if($CategoryID == "9") {
$image = "Images/runningdogbg.jpg";
}else if($CategoryID == "13") {
$image = "Images/girlndogbg1.jpg";
}else if($CategoryID == "15") {
$image = "Images/hkgirlndogbg.jpg";
}else if($CategoryID == "16") {
$image = "Images/hkgirlndogbg.jpg";
}else if($CategoryID == "17") {
$image = "Images/girlndogbg1.jpg";
}else if($CategoryID == "18") {
$image = "Images/girlndogbg1.jpg";
}else if($CategoryID == "19") {
$image = "Images/2dogsandacatnewwysong.jpg";
}else if($CategoryID == "20") {
$image = "Images/2dogsandacatnewwysong.jpg";
}else if($CategoryID == "21") {
$image = "Images/storeMessage_bgboydog.jpg";
}else if($CategoryID == "22") {
$image = "Images/storeMessage_bgboydog.jpg";
}else if($CategoryID == "24") {
$image = "Images/storeMessage_bgtruelove.jpg";
}else if($CategoryID == "25") {
$image = "Images/runningdogbg.jpg";
}
?>
<div id="storeMessage2" style="background-image:url(<?php echo $image; ?>)">
<h1><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<h1><span class="style8"><br />
<br />
<br />
&nbsp; &nbsp;<span class="style16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="style20">The Natural Path to Better Pet Health</span></span></span></h1></h1>
</div>
<div id="contentWrapper">
<div id="leftColumn1">
<?php require_once("CSSMenuWriter/intermediate.php"); ?>
</div>

but now get

Notice: Undefined index: CategoryID in C:\wamp\www\PowerStore200\Products_Detail.php on line 390

or

Notice: Undefined index: CategoryID in C:\wamp\www\PowerStore200\Products_Results.php on line 309

which are where the PHP for storeMessage starts...

which is no doubt because I've yet to update the links, right?

I'll do that now... the non-product pages are still worrying me!

Thanks, Dani!

Sign in to reply to this post

Dani Chankhour

You are correct, if you just add the else to the end, which will be your default image:

}else {
$image = "default.jpg";
}

and change your first line to say:

$CategoryID = (isset($_GET['CategoryID']))?$_GET['CategoryID']:"";

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...