Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Code used to produce styled image links on www.pro-fish.co.uk
- // Creating new content is a simple matter of adding a new MediaLink to the array
- // Create a struct for the links
- class MediaLink
- {
- public $nameReadable;
- public $nameInternal;
- public $href;
- public $imageSrc;
- public $title;
- function __construct($humanName, $internalName, $linkURL, $imageURL, $linkTitle) {
- $this->nameReadable=$humanName;
- $this->nameInternal=$internalName;
- $this->href=$linkURL;
- $this->imageSrc=$imageURL;
- $this->title=$linkTitle;
- }
- }
- // Example array of links to be created
- $pageLinks = array(
- new MediaLink("Bitbucket", "bitbucket",
- "https://bitbucket.org/",
- "img/bitbucket-icon.png",
- "Bitbucket Repository"),
- new MediaLink("Pastebin", "pastebin",
- "http://pastebin.com/",
- "img/pastebin-icon.jpeg",
- "Pastebin Repository"),
- new MediaLink("Twitter", "twitter",
- "http://www.twitter.com/",
- "img/twitter-icon.png",
- "Twitter Feed"),
- new MediaLink("LinkedIn", "linkedin",
- "http://uk.linkedin.com/",
- "img/linkedin-icon.png",
- "LinkedIn Portfolio"),
- new MediaLink("Stack Overflow","stackoverflow",
- "http://stackoverflow.com/",
- "img/stackoverflow-icon.jpg",
- "StackOverflow Profile"),
- new MediaLink("SO Careers", "careersso",
- "http://careers.stackoverflow.com/",
- "img/socareers-icon.png",
- "StackOverflow Careers Profile")
- );
- // Output all links as images
- function CreateImageLinks($pageLinks)
- {
- // Write HTML to page
- foreach ($pageLinks as $link)
- {
- echo "<div class='imgLink'>";
- echo "<a href='$link->href' target='_blank' title='$link->title'>\n";
- echo "<img src='$link->imageSrc' alt='$link->nameReadable'/></a></div>\n";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement