News:

The anti-spam plugins have stopped being effective. Registration is back to requiring approval. After registering, you must ALSO email me with your username, so that I can manually approve your account.

Main Menu

Need help on randomly displaying images w/ hyperlinks

Started by fesworks, November 09, 2006, 01:27:04 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

fesworks

Ok, the cookie thing would be ok, (#2) but what about when the block cookies? does it just randomly pick a new banner each reload? Also, how does #3 work? I mean, it looks like it may need to make a new file for each and every visitor, or that every visitor shares the same file?

Also, I can't tell from your code where you put the code to say what to display "Banner 2 gets displayed this time" etc...

might it be something like this? :

if($banner== 1) { ?>



A description of above site.

if($banner== 2) { ?>



A description of above site.

if($banner== 3) { ?>



A description of above site.
and where would this be placed?




Personally, I was thinking of a pre-set list of sites, with the first one being randomly picked (which I think does not need cookies, thus less searching and loading?), along with links for "Previous" and "Next" to go along the given list.... also, as a new thought, I'll also need a link that will point

Also, the thing is that , for people to be able to put this onto their HTM pages, this is going to be a seperate page, so people can have an iframe code. I'm going to have a button link within the iframe'd page to reload itself... that or I was going make a link for "next" in the list. How would I make a "next" link in PhP for this banner array?

I mean with that in mind I could do it with a bunch of HTM pages and code, but I'm sure it would take a much longer loading time and a ton of extra space and code.... to what would certianly be a something horrifically archaic to the both of you.




ok, here,  this I was just thinking about doing:


The "<<" and ">>" would be linking to "Previous" and "Next" on the given list.

Inbetween that would be static text and/or a custom Xepher.net image with some sort of moto or such like I have listed there.

Under that would be where the banner and description would be. The banner will carry the link to that site.

under that is my new idea and "Link1", "Link2", "Link3", and "Link4" would point to different list sets (either as a different page altogether or just a different TEXT LIST (which I think is what you were talking about). The lists would be like what is one Xepher.net.... one link for "Art", one for "Comics", one for "Fiction", and one for "Others"... and if they click on "Comics" while already on the comics list, it could just pick something from the list at random.



ok, I hope that is descriptive enough, and not too complicated. Those multiple link sets are the new idea, so that is an extra thought.

Also, I greatly thank everyone for their help with this! I don't mean to look all needy/difficult because I can't do this myself : When I can piece everything together (including either snatching or creating banners for all sites here). I'll post it. I think this could be a really cool addition for those that would like to pimp other xepher sites in an interactive way.


Unless I'm making this more complicated than it needs too be :P

www.PSIwebcomic.com
www.TheShifterArchive.com
www.ArdraComic.com
www.WebcomicBeacon.com

Omega0

>> Ok, the cookie thing would be ok, (#2) but what about when the block cookies?
When cookies are disabled, it follows the else-branch from the isset() and chooses a random one from the full list.

>> Also, how does #3 work? I mean, it looks like it may need to make a new file for each and every visitor, or that every visitor shares the same file?
One file.  Visitor 1 gets banner one, Visitor 2 gets banner 2, Visitor 3 gets banner 3, Visitor 4 gets banner 1 and so on.  There's just one current banner, whoever loads the page next gets it.

>>Also, I can't tell from your code where you put the code to say what to display "Banner 2 gets displayed this time" etc...
My code just sets a variable $banner which later in the page is used in the if's to display the text; I think you have the right idea in your code (though I've never used that construction in PHP).  Since cookies have to be set before any output occurs, the banner selection code is at the top of the file and the if's come later where the banner is supposed to go.  The link at the end of this post shows the code I used.

>>How would I make a "next" link in PhP for this banner array?
With HTTP_POST_VARS[] overriding the cookie or random behavior.  If the current banner is #2, The next link would be something like "bannerbox.php?banner=3"  The code would be something like
if isset( HTTP_POST_VARS['banner'] then $banner = HTTP_POST_VARS['banner']
else $banner = COOKIE or random as previously

Demo: http://omega0.xepher.net/stuff/bannerbox.php
Code: http://omega0.xepher.net/stuff/bannerbox.txt

Databits

Far as I'm concerned... if a user has cookies blocked, they're morons and they shouldn't be on the net anyhow.

Contrary to belief, there is nothing insecure about having a website set a cookie in your web browser. The only problem is when some dumb sites store sensitive information in their cookies, which even in that case, other sites can't read that information anyhow.

It's under the same situation as people who disable Javascript for security, also really dumb. There's a lot of commerce sites that make use of things like Ajax, which is impossible for people to use when they have no Javascript. People shouldn't need to set their sites up to give leeway to those who don't really know what they're talking about and wanna disable everything thinking it'll stop the virus from getting on their computer while they browse porn and download illegal software.
(\_/)    ~Relakuyae D'Selemae
(o.O)    
(")_(")  [Libre Office] [Chrome]

Xepher

Fes: I think Omega answered your question(s) again, so I'll let you digest that before adding more. Don't worry about asking too many questions though, we're glad to help. What you're trying to do is actually quite simple, once you get down to it. It's actually probably harder to explain than to do. The trick is getting all the code details right (like which bracket goes where.) As I don't program all the time, I know concepts just fine, but I forget syntax when I'm just winging it or pasting snippets, so if something I've given you doesn't work, often I've just overlooked some stupid detail. Perhaps if I get some free time later, I can actually write out an effective script for what you want to do. Can't promise anything though.

Data: Blocking cookies doesn't really improve anti-virus measures, but it does help with your privacy, if you're the sort to be concerned about that. Many ad/banner companies send cookies with with ads, effectively giving you a fingerprint. As you browse around other places, they track your usage patterns for market research. Some people feel that's an invasion of their privacy, and block cookies. Now, that said, if something's broken because you're blocking cookies indiscriminately, that's your own dang fault! :-)

fesworks

Haha, Actually I block every single thing that pops up unless I need to log in to the site :P (I have it ask every time).


as far as the code. Well, I'll see what I can do with what I can figure out from these code pieces. But from this point I think I'll be able to make something. I'll need to work on it later in the week though.

Thank again for the ongoing help, and don;t worry about me asking questions.... because I sure will ;) :P

www.PSIwebcomic.com
www.TheShifterArchive.com
www.ArdraComic.com
www.WebcomicBeacon.com

fesworks

Oh man, I looked at that code... all of the codes... I just can't wrap my head around how to place ANY of it in a proper sequence, let along get it to place images! I know nothing about PHP unless its already in place and works, I can modify it... But I just can't figure this out!

All the images should exist in the same folder... all of the comics with their image and text should be listed in it's own array....


(opps, forgot to change the bottom images brackets to "Prev" and "Next")

Can't I just give one of you $20 (all I can do) to figure out the base code for this in a cookie-less, extra text file-less (if possible) code? I can be more exact and descriptive if needed... I just need the base, and I can plug all the individual banner img addresses and text phrases in.. I just need an exaple and placement markings.

If not possible I'll try and troll the internet for pre-made ones I can used, or do the whole thing in HTML and a 75 pages or something.

I just can't piece all of these PHP code fragments together. Sorry! I don'r mean to be so difficult sounding!

www.PSIwebcomic.com
www.TheShifterArchive.com
www.ArdraComic.com
www.WebcomicBeacon.com

Xepher

I can do it when I get a little bit of free time... probably tomorrow or saturday. Don't worry about the money, I help when I can. Besides, I need similar code for some of my own stuff in the future, so it wouldn't hurt me to have some snippets lying around.

Let me see if I've got the details straight first though:

1. Main image and text. These always go together... that is, a particular image always has a specific text block with it. Image & Description. These get shown...

2. ...Randomly on first view. Next + Previous buttons let people flip though them in order.

3. (This is the one I'm confused on.) You obviously want it to not show the same image over and over to the same person if they're viewing a lot of pages with the banner code in it. How do you want it to work though. Do you want it to rotate per person? (In which the script saves it's current position in a cookie) Or rotate for the site as a whole? (which would involve storing the current position in a small file.) You says cookie-less and file-less, but you really have to have one or the other unless you resort to URL trickery, with the code adding something like "index.php?session_id=297597829adf7897f09a0dfjd9d77" to each URL and link on your site. I don't think you want that. I'd suggest the cookie method, as it should work best for about 90-95% of people.

4. The buttons at the bottom (comics, art, fiction, other)... how do they work? I notice that they highlight based on the category of the current image displayed, but does the function change? That is, does it do something different when I click based on what image is showing, or is it the same link all the time?

Let me know on those, and I'll see what I can whip up for you.

fesworks

1) Yep

2) Yep

3) My plan was for the think to be only shown on a sinlge page (home page or Links page... where evern other Xepherers would like to put them if they'd want one).... I planned to have all the code on a PHP page that could be iframed for loading and re-coding effieniency.

All I was thinking is that the first one would be randomly picked from the list (on first load and on refresh). Then just go in order from there and go back to the top of the list once you get to the end.

I don;t think that cookies would be needed because a list would be big enough for a decent random pick anyway, and should streamline the code and loading if it does not need to check a cookie somewhere.


4) Basically, i'm thinking of List sorting... "Arrays" are they? Like the link box would always start on "Comics", and then the random image/text set will be shown from a list or array of sets of just listed webcomics on Xepher.... You click "Art" and a new random image/text set will be selected from a list or array of only Art sites on Xepher.

Now I'm saying it like this because I'm assuming that having a sepperate list would be helpful with checking codes.

Like:

IF click "Comics" GOTO "ComicsLIST"
IF click "Art" GOTO "ArtLIST"
IF click "Fiction" GOTO "FictionLIST"
IF click "Comics" GOTO "OtherssLIST"


LABEL ComicsLIST"
comic_1_Image
comic_1_Text
etc..
END GOTO "ComicsLIST"

LABEL  "ArtLIST"
Fiction_1_Image
Fiction_1_Text
etc..
END GOTO "ArtLIST"

LABEL "FictionLIST"
Fiction_1_Image
Fiction_1_Text
etc..
END GOTO "FictionLIST"

LABEL "OtherssLIST"
Others_1_Image
Others_1_Text
etc..
END GOTO "OtherssLIST"

At least that is what I was thinking... and then when one clicks NEXT or PREV they stay in that list. I'm guessing they may need to have different pages for seperate lists, But I don't know.


5) You know how the Xepher News Box is Editable? Well, If I make it an iframe, it may not work that well like that, so I'm probably make different pages. One for each of trhe four categories to start with. So an art site can link to the page that starts with the art section.


I'm sure this could be done like the Xepher news box.... all the code at the tope of the page with that one line to place it where you'd like it.. customize colors? But that, I'm sure is a bit fancier and more involved coding.... Not meaning to get really complicated! I mean, I originally meant it to be a simple alternative/addition to the texty Xepher New Box.  I really wanted to better visually promote the Xepher.Net webcomic community :D

www.PSIwebcomic.com
www.TheShifterArchive.com
www.ArdraComic.com
www.WebcomicBeacon.com

Xepher

I've actually had plans for a while to eventually integrate images into the Site Descriptions you can set for your site, and they'd show up in the newsbox instead of just a text description. Also some code to make it so you can see different banners/text BEFORE selecting a site to go to from the dropdown. I just never got around to it.

Okay, on item 4... I think I know what you want now. You used more technical terms than I want to guess at. I don't speak programming, I just know what I want in plain english. :-) On that note, you want people to click the "art" button, and have it load a random art banner/text, at which point next/prev buttons would flip through only art sites. Similar situation for the other buttons. Is that right?

As for customization, as per the XN newsbox... It's doable. Though for this idea, I'm not sure you want it. If site owners can change the colors and what not, you end up with radically different looks. So one artist designs their banner to go with how they have their box laid out, but then it shows up on another site and looks totally out of place. Or someone sets it to white-on-white or something. I'd say just make it as as simple as possible, but keep it standardized.

About embedability... that is, putting it as part of the actual page like the newsbox: That only works (via PHP) on one server, since all the boxes would get displayed by the same server, it can do that. To enable it to be done on other servers, you need iframes, javascript, or another server with a rather insecure PHP installation that allows inserting code from remote servers. Bottom line is that anyone can use an iframe, only people with pages in PHP can use a direct PHP insertion.

fesworks

Quote from: XepherI've actually had plans for a while to eventually integrate images into the Site Descriptions you can set for your site, and they'd show up in the newsbox instead of just a text description. Also some code to make it so you can see different banners/text BEFORE selecting a site to go to from the dropdown. I just never got around to it.
Well I was hoping to make something like that because your text version is boring :P but, alas, coding this stuff is not my forté.

Quote from: XepherOkay, on item 4... I think I know what you want now. You used more technical terms than I want to guess at. I don't speak programming, I just know what I want in plain english. :-) On that note, you want people to click the "art" button, and have it load a random art banner/text, at which point next/prev buttons would flip through only art sites. Similar situation for the other buttons. Is that right?
Yes.


Quote from: XepherAs for customization, as per the XN newsbox... It's doable. Though for this idea, I'm not sure you want it. If site owners can change the colors and what not, you end up with radically different looks. So one artist designs their banner to go with how they have their box laid out, but then it shows up on another site and looks totally out of place. Or someone sets it to white-on-white or something. I'd say just make it as as simple as possible, but keep it standardized.
k

Quote from: XepherAbout embedability... that is, putting it as part of the actual page like the newsbox: That only works (via PHP) on one server, since all the boxes would get displayed by the same server, it can do that. To enable it to be done on other servers, you need iframes, javascript, or another server with a rather insecure PHP installation that allows inserting code from remote servers. Bottom line is that anyone can use an iframe, only people with pages in PHP can use a direct PHP insertion.
Well I was thinking that people would just get the iframe code from me, so they would not have to worry about uploading the image sets or whatnot... and people could just iframe it to a PHP page on my account, so if I need to add a newly approved account, I could easily change it for everyone without having people bothering with the code again.

If you know what I'm talking about... basicaly make it easy for others to implement, so they would be more inclined to do add it to their site.


I mean, if you want to take these ideas and use it for your new News Box, go right ahead, The only part that would be difficult would be the image display, which would mean that by how people have the news box on their site, the images would have to be Avatar size instead of Banner size, like that Cornstalker thing I showed you earlier..

www.PSIwebcomic.com
www.TheShifterArchive.com
www.ArdraComic.com
www.WebcomicBeacon.com

Databits

You may also try storing image data in the database. Since databases are much faster than just straight file system access, and benchmarks for images in a database are surprisingly fast. The only issue you run into then is writing a serving script (which really isn't hard to do) to pull the image from the db and give the correct image headers. In which case you can just tell a query to pull one at random I'm sure.

Then you'd have something like this for images on your site:

....On a side note, the standard php mysql connection stuff is really a pain in the butt to use and not very friendly. I would suggest to use something like PEAR::MDB2 if Xepher would install it. It's really a kick ass setup and makes a TON of things easier, and the best part is you can change up the database back end on your site and need to make few code changes most the time.
(\_/)    ~Relakuyae D'Selemae
(o.O)    
(")_(")  [Libre Office] [Chrome]

Xepher

Funny, I've never had a problem with the standard MySQL functions... but maybe it's just a case of not knowing what I'm missing. As for PEAR::MDB2... like VIM, just ask, and I can usually install most things. For this particular project though, I think I'm just going to write a simple little script with flat file (or maybe sqlite) storage. I want something fes can understand and tweak if he wants. Later, when I implement something for the site as a whole, I may do some more advanced stuff. I've consider image storage in database blobs for a while now, but I read pros and cons about it, so I'll wait for the right place/time to do it.

Xepher

Okay, I've got code that does your banner exchange EXCEPT for categories. I went to tack on the categories and hit a small bump, so I may rewrite the whole thing, but if I do, it's going to be rather more complex. As such, I wanted to go ahead and post this simple-yet-ugly version for you to look at and maybe learn from while it's still possible to deduce what things are doing.

Working example at http://xepher.xepher.net/Banners/banner.php

Code for that file is http://xepher.xepher.net/Banners/banner-source.php


Now, back to trying categories... to database or not to database, that is the question. :-)

fesworks

Hey, even without the additiona categories that's fine. Since it seems like you had a similar idea for the news box already (if I understood you right).

I can use this as the original idea as the Xepher Comic thingee (to start) at least.

Thanks! I'll work on this :D

www.PSIwebcomic.com
www.TheShifterArchive.com
www.ArdraComic.com
www.WebcomicBeacon.com

fesworks

Hey someone said I could do something on my computer so I can run PHP.... right now I just basically keep uploading it to my account to view changes.... how do I make Frontpage or Dreamweaver perform the PHP code (if possible)?

www.PSIwebcomic.com
www.TheShifterArchive.com
www.ArdraComic.com
www.WebcomicBeacon.com