kiddink Posted July 7, 2010 Share Posted July 7, 2010 I want to show a picture of a dog, if the page that im on is mywebsite.com/dog now this sounds easy but im using wordpress. which basically only has like, index.php, sidebar.php, etc etc and basically it builds the pages on the fly, depending on which category I choose. so in my sidebar.php, i need some sort of code that says: if(currenturl = theurlIpicked) <img src = blah blah> else blah blah that way when the sidebar.php loads, if the url isn't the one that I want, it just won't load that image. i have 0 php knowledge so I need you guys's help thanks again Link to comment https://forums.phpfreaks.com/topic/207070-i-want-to-a-show-a-picture-on-a-page-depending-on-the-url-that-the-user-is-seein/ Share on other sites More sharing options...
kiddink Posted July 7, 2010 Author Share Posted July 7, 2010 ^^^huh? Link to comment https://forums.phpfreaks.com/topic/207070-i-want-to-a-show-a-picture-on-a-page-depending-on-the-url-that-the-user-is-seein/#findComment-1082743 Share on other sites More sharing options...
Dragosvr92 Posted July 7, 2010 Share Posted July 7, 2010 why dont you just add the image on the respective page ? Link to comment https://forums.phpfreaks.com/topic/207070-i-want-to-a-show-a-picture-on-a-page-depending-on-the-url-that-the-user-is-seein/#findComment-1082747 Share on other sites More sharing options...
kiddink Posted July 7, 2010 Author Share Posted July 7, 2010 why dont you just add the image on the respective page ? you didn't read my post did you? im using wordpress which is basically like a blogging tool. i have 8 php files. archives, post, welcome.php, index.php, sidebar, main index template, etc etc etc so there is no .php file or .html for an actual page. at least i cant access it or i dunno how? is there a code that checks for the url? Link to comment https://forums.phpfreaks.com/topic/207070-i-want-to-a-show-a-picture-on-a-page-depending-on-the-url-that-the-user-is-seein/#findComment-1082749 Share on other sites More sharing options...
Dragosvr92 Posted July 7, 2010 Share Posted July 7, 2010 how many pages do you have on a .php file? can you post a link to the page? Link to comment https://forums.phpfreaks.com/topic/207070-i-want-to-a-show-a-picture-on-a-page-depending-on-the-url-that-the-user-is-seein/#findComment-1082753 Share on other sites More sharing options...
kiddink Posted July 7, 2010 Author Share Posted July 7, 2010 how many pages do you have on a .php file? can you post a link to the page? the website is things4cheap.com, you'll be redirected to different pages such as things4cheap.com/categories/baby-items, but i do not have a baby-items.php FILE, it builds everything in real time. Link to comment https://forums.phpfreaks.com/topic/207070-i-want-to-a-show-a-picture-on-a-page-depending-on-the-url-that-the-user-is-seein/#findComment-1082754 Share on other sites More sharing options...
kiddink Posted July 8, 2010 Author Share Posted July 8, 2010 anybody? c'mon guys this is probably so easy for you like, if(myurl == "chosenurl") { } just give me the php if statement with that condition and i know how to do the rest. it's just i have 0 coding experience in php. Link to comment https://forums.phpfreaks.com/topic/207070-i-want-to-a-show-a-picture-on-a-page-depending-on-the-url-that-the-user-is-seein/#findComment-1083043 Share on other sites More sharing options...
Dragosvr92 Posted July 8, 2010 Share Posted July 8, 2010 do you know how to rename the index page with the category links ? for example to modify this link from http://things4cheap.com/categories/baby-items to: http://things4cheap.com/categories/baby-items?img=+ Link to comment https://forums.phpfreaks.com/topic/207070-i-want-to-a-show-a-picture-on-a-page-depending-on-the-url-that-the-user-is-seein/#findComment-1083298 Share on other sites More sharing options...
icez Posted July 9, 2010 Share Posted July 9, 2010 <?php function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } ?> <?php if(curPageURL() == 'http://yourwebsite.com/category/dog') { echo '<img src="" />'; } ?> Should work, didn't test it. Link to comment https://forums.phpfreaks.com/topic/207070-i-want-to-a-show-a-picture-on-a-page-depending-on-the-url-that-the-user-is-seein/#findComment-1083351 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.