Author Topic: Making a webcomic: "dynamic hyperlinks"  (Read 11639 times)

0 Members and 1 Guest are viewing this topic.

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Making a webcomic: "dynamic hyperlinks"
« on: September 20, 2011, 09:57:17 pm »
Yeah, so I'm starting my first foray into web development (yay!) And I'm trying to build a webcomic (yay!) Except I don't know how.

I get html and css, the design isn't the problem. The problem for me are the "next" and "previous" buttons. I can think of two ways to make them work properly:

1) Every webpage has unique hyperlinks (pain in the butt and kinda inefficient)
2) Use some scripty thing to define where these buttons will direct the user.

So, my question is, what's the best way to do this? Am I overestimating how inefficient option 1 will be? How can I even do option 2? I skimmed over some javascript/php/asp tutorials but nothing jumped out at me as being able to do this.

Note: The comics would be numbered I guess. Like XKCD and cyanide/happiness and every other webcomic there is. LOL

Thanks in advance :D

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Making a webcomic: "dynamic hyperlinks"
« Reply #1 on: September 20, 2011, 10:09:52 pm »
Yeah, you would get the comic number from the url ($_GET in PHP) then do +1 and -1 for the mext amd prev buttons.

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline BlakPilar

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 734
  • Rating: +44/-1
    • View Profile
Re: Making a webcomic: "dynamic hyperlinks"
« Reply #2 on: September 20, 2011, 10:12:37 pm »
Yeah, you could use PHP like Juju said or, my personal favorite, ASP(.NET).

Offline XVicarious

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +45/-28
  • I F**king Love Twisty Puzzles
    • View Profile
    • XVicarious
Re: Making a webcomic: "dynamic hyperlinks"
« Reply #3 on: September 20, 2011, 10:13:34 pm »
Use PHP, its pretty much standard. And there are WAY more resources out there. Hell I could help you.

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Making a webcomic: "dynamic hyperlinks"
« Reply #4 on: September 20, 2011, 11:00:45 pm »
Hmm, could I get some help? It's kinda annoying that I can't test out PHP scripts offline, i'm waiting for the nameservers to resolve atm.

I see that the $_GET function gets the variable off the url, so if the variable is p and the url is blah/?p=10 the $_GET[p]=1, right? Then what- do you just do like $_GET[p]+1=$_GET[p]?

Offline cooliojazz

  • Support Staff
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 619
  • Rating: +66/-9
  • I omnoms on your soul
    • View Profile
    • Unreal Phantasies
Re: Making a webcomic: "dynamic hyperlinks"
« Reply #5 on: September 20, 2011, 11:12:08 pm »
Code: (php) [Select]
<?php $cur $_GET[&#39;p&#39;]; ?>
<a href="/?p=<?php echo $cur 1?>"><img src="thebestprevbuttonever"></a><a href="/?p=<?php echo $cur 1?>"><img src="thebestnextbuttonever"></a>
This would show two buttons, one linking to the previous comic, one linking to the next. (You could also add something like changing "$cur - 1" to "$cur > 0 ? $cur - 1 : 0" and "$cur + 1" to "$cur < $max ? $cur + 1 : $max" for safety as long as you always changed $max to the current comic number)  Need anything else?
« Last Edit: September 20, 2011, 11:13:22 pm by cooliojazz »
Spoiler For Random signess:
You can not beat my skills.
Trust me.
So don't even try.
And remember never to trust someone who says, "Trust me."

TI File Editor Progress: Remade in java like a boss. 50% we'll call it? IDK =P
Java Libraries: JIRC - 90% JTIF - 5%
TI Projects: Unreal Notator - -5000%
Nomcraft, a Bukkit mod
Some of the music I write can be found here | The Rest Should Be Here (Bandcamp)

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Making a webcomic: "dynamic hyperlinks"
« Reply #6 on: September 20, 2011, 11:21:41 pm »
Hmm, could I get some help? It's kinda annoying that I can't test out PHP scripts offline, i'm waiting for the nameservers to resolve atm.
You should try working with xampp for offline testing :)
http://www.apachefriends.org/en/xampp.html
http://portableapps.com/apps/development/xampp
/e

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Making a webcomic: "dynamic hyperlinks"
« Reply #7 on: September 21, 2011, 11:15:38 am »
Code: (php) [Select]
<?php $cur $_GET[&#39;p&#39;]; ?>
<a href="/?p=<?php echo $cur 1?>"><img src="thebestprevbuttonever"></a><a href="/?p=<?php echo $cur 1?>"><img src="thebestnextbuttonever"></a>
This would show two buttons, one linking to the previous comic, one linking to the next. (You could also add something like changing "$cur - 1" to "$cur > 0 ? $cur - 1 : 0" and "$cur + 1" to "$cur < $max ? $cur + 1 : $max" for safety as long as you always changed $max to the current comic number)  Need anything else?

Oh wow, I didn't realize that php outputs html LOL. Thanks :D. So just to clarify, I would then have to name each comic's page /?p=#, correct?
« Last Edit: September 21, 2011, 11:27:07 am by squidgetx »

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Making a webcomic: "dynamic hyperlinks"
« Reply #8 on: September 21, 2011, 02:09:52 pm »
Oh wow, I didn't realize that php outputs html LOL. Thanks :D. So just to clarify, I would then have to name each comic's page /?p=#, correct?
No, you would have to somehow fetch the image of each comic with this one page. Something like:
Code: [Select]
<img src="img/page_<?php echo $cur?>.png"/> you would then store all your comics in img/ named page_#.png
« Last Edit: September 21, 2011, 02:10:07 pm by Eeems »
/e

Offline cooliojazz

  • Support Staff
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 619
  • Rating: +66/-9
  • I omnoms on your soul
    • View Profile
    • Unreal Phantasies
Re: Making a webcomic: "dynamic hyperlinks"
« Reply #9 on: September 21, 2011, 02:15:39 pm »
well, it would be one file, "index.php" which you can pass different arguments for the page numbers.  That code just takes the argument and outputs buttons linking to the right page, so you don't really "name" them, other than the one main file, which is probably going to be index.php.  Does that make sense and answer the question?
Darn you ninjas!!! But yes, also what Eeems said =P
Spoiler For Random signess:
You can not beat my skills.
Trust me.
So don't even try.
And remember never to trust someone who says, "Trust me."

TI File Editor Progress: Remade in java like a boss. 50% we'll call it? IDK =P
Java Libraries: JIRC - 90% JTIF - 5%
TI Projects: Unreal Notator - -5000%
Nomcraft, a Bukkit mod
Some of the music I write can be found here | The Rest Should Be Here (Bandcamp)

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Making a webcomic: "dynamic hyperlinks"
« Reply #10 on: September 21, 2011, 02:25:09 pm »
well, it would be one file, "index.php" which you can pass different arguments for the page numbers.  That code just takes the argument and outputs buttons linking to the right page, so you don't really "name" them, other than the one main file, which is probably going to be index.php.  Does that make sense and answer the question?
I was thinking about saying something about index.php
Darn you ninjas!!! But yes, also what Eeems said =P
You should turn on the option to keep people from ninja'ing you
/e

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Making a webcomic: "dynamic hyperlinks"
« Reply #11 on: September 21, 2011, 03:47:48 pm »
Ok, I see. Wow, php is pretty powerful lol. And then for alt text and stuff should I use an xml file?
Code: (xml) [Select]
<1><title>Title</title><alt>Alt text</alt></1>
Code: (php) [Select]
<h2><?php echo $xml->$cur->title ?> </h2>
<img.... title=<?php $xml->$cur->alt ?>>

Does this work?
« Last Edit: September 21, 2011, 03:57:29 pm by squidgetx »

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Making a webcomic: "dynamic hyperlinks"
« Reply #12 on: September 21, 2011, 04:25:40 pm »
Ok, I see. Wow, php is pretty powerful lol. And then for alt text and stuff should I use an xml file?
Code: (xml) [Select]
<1><title>Title</title><alt>Alt text</alt></1>
Code: (php) [Select]
<h2><?php echo $xml->$cur->title ?> </h2>
<img.... title=<?php $xml->$cur->alt ?>>

Does this work?
I'm not sure if that works. You could always use flat text files for each of them, so have title/ contain page_# with the title text/page_# contain the alt text etc
Just use file_get_contents("path/to/file_{$cur}"); to get the contents of the file.
/e

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Making a webcomic: "dynamic hyperlinks"
« Reply #13 on: September 21, 2011, 04:56:33 pm »
So every comic would then be accompanied by 2 txt files, one like named alt1 and the other named title1? I see how I can use file_get_contents, but is there a way to have all the titles and text in one file? Or am I not understanding what you're saying?
« Last Edit: September 21, 2011, 04:58:21 pm by squidgetx »

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Making a webcomic: "dynamic hyperlinks"
« Reply #14 on: September 21, 2011, 04:59:18 pm »
You could use xml, I'm just not sure if you can access it that way, feel free to try it out though. You could also use flat text files if you did some nice formatting, like grabbing the title from the first line, the alt text from the second line and the rest of the content from whatever is leftover.
/e