Jump to content

meylo

New Members
  • Posts

    5
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

meylo's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ohhhhh "for each"! Got it. It works now.
  2. I'm trying to keep up with PHP as I am learning. I seems that Exclusive is spelled correctly and I so have $beer variable. So I'm a little confused.
  3. Thank you for the help. Here's what I am getting with the added code you provided. Test Page: http://graintoglass.com/fb/tap-menu-test.php It seems that I get the default logo all the way through. I just need the default logo to show when the image endpoint is empty. Most recent code effort <?php $url = 'http://mcallen.taphunter.com/widgets/locationWidget?location=Grain-To-Glass&format=jsonv2short'; $curl_session = curl_init($url); curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_session, CURLOPT_CONNECTTIMEOUT, 4); curl_setopt($curl_session, CURLOPT_TIMEOUT, 10); $data = curl_exec($curl_session); curl_close($curl_session); $beer_list = json_decode($data); $logo_image = empty($beer->brewery->logo_url) ? 'GrainToGlassExclusive.gif' // use this default image if brewery->logo_url is empty : $beer->brewery->logo_url; // use the brewery logo from json if it is not empty echo '<p class="last-updated">Last Updated: ' . date("m/d/Y") . '</p>'; echo '<h1 class="page-title">Tap Menu</h1>'; echo '<p class="page-intro">You have stumbled upon the treasure chest of delicious drinking. From dark porters and stouts to light pilsners and hefeweizens, we have a variety of beer styles to match your beer palette. You might want to refresh your browser often, because we add new kegs daily. It is safe to say our tap list is always up to date.</p>'; foreach ($beer_list as $beer) { echo '<article class="beer-entry"> <div class="beer-image"><img src="'.$logo_image.'" /> </div> <div class="beer-info"> <p class="brewery-name">'.$beer->brewery->name.' — '.$beer->brewery->origin.'</p> <h2 class="beer-name">'.$beer->beer->name.'</h2> <p class="beer-style">Beer Style: '.$beer->beer->style.'</p> <p class="beer-description">'.$beer->descriptions->short_description.'</p> <p class="beer-abv">ABV: '.$beer->beer->abv.' / IBU: '.$beer->beer->ibu.'</p> <p class="beer-ibu"></p> </div> <div class="clearfix"></div> </article> '; } echo '<p class="page-bottom">If you would like to see more of our food and beer options, <a href="https://www.graintoglass.com" target="_blank">visit our website</a>.</p>'; ?>
  4. Can anyone help by shedding some light with a little problem I encounter using JSON endpoint requests. I'm not very good with PHP. When the endpoint is called and finds no data, I want to replace it with a local image source. In this case, I am calling brewery->logo_url. Most entries have endpoints, but some don't. When an image link is found at the endpoint, it throws off my layout. You can see the ones that look off. They align to the left. I want to replace with a logo default image each time this happens, with hopes to set the layout adjust back to normal. Here's my working document http://graintoglass.com/fb/tap-menu-test.php and here's the JSON. http://mcallen.taphunter.com/widgets/locationWidget?location=Grain-To-Glass&format=jsonv2short Code Effort <?php $url = 'http://mcallen.taphunter.com/widgets/locationWidget?location=Grain-To-Glass&format=jsonv2short&servingtype=bottlecan'; $curl_session = curl_init($url); curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_session, CURLOPT_CONNECTTIMEOUT, 4); curl_setopt($curl_session, CURLOPT_TIMEOUT, 10); $data = curl_exec($curl_session); curl_close($curl_session); $beer_list = json_decode($data); echo '<p class="last-updated">Last Updated: ' . date("m/d/Y") . '</p>'; echo '<h1 class="page-title">Bottle List</h1>'; echo '<p class="page-intro">Not only do we serve a hefty list of brews on tap, we also offer an exclusive list of beers in bottle. Our bottle list is constantly changing so the occasional return visits to browse this list is the best way to stay up to date. Take a look!</p>'; foreach ($beer_list as $beer) { echo '<article class="beer-entry"> <div class="beer-image"><img src="'.$beer->brewery->logo_url.'" /></div> <div class="beer-info"> <p class="brewery-name">'.$beer->brewery->name.' — '.$beer->brewery->origin.'</p> <h2 class="beer-name">'.$beer->beer->name.'</h2> <p class="beer-style">Beer Style: '.$beer->beer->style.'</p> <p class="beer-description">'.$beer->descriptions->short_description.'</p> <p class="beer-abv">ABV: '.$beer->beer->abv.' / IBU: '.$beer->beer->ibu.'</p> <p class="beer-ibu"></p> </div> <div class="clearfix"></div> </article> '; } echo '<p class="page-bottom">If you would like to see more of our food and beer options, <a href="https://www.graintoglass.com" target="_blank">visit our website</a>.</p>'; ?>
  5. I'm so close to getting this to work for me but I am getting some what seem to be permissions errors, which I have changed to 777... can anyone please help out? See errors below. Warning: fopen(/5b3c508edf41ed153b0e8edd89366995.cache) [function.fopen]: failed to open stream: Permission denied in /homepages/22/d290858159/htdocs/tmu/wp-content/themes/default/flickr/phpFlickr.php on line 182 Warning: fwrite(): supplied argument is not a valid stream resource in /homepages/22/d290858159/htdocs/tmu/wp-content/themes/default/flickr/phpFlickr.php on line 183 Warning: fclose(): supplied argument is not a valid stream resource in /homepages/22/d290858159/htdocs/tmu/wp-content/themes/default/flickr/phpFlickr.php on line 184 Warning: fopen(/32f9ebc781a534c1da1ef2bfb5ea35f7.cache) [function.fopen]: failed to open stream: Permission denied in /homepages/22/d290858159/htdocs/tmu/wp-content/themes/default/flickr/phpFlickr.php on line 182 Warning: fwrite(): supplied argument is not a valid stream resource in /homepages/22/d290858159/htdocs/tmu/wp-content/themes/default/flickr/phpFlickr.php on line 183 Warning: fclose(): supplied argument is not a valid stream resource in /homepages/22/d290858159/htdocs/tmu/wp-content/themes/default/flickr/phpFlickr.php on line 184 the website is www.theymeanus.com/pics
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.