Lovac Posted January 13, 2010 Share Posted January 13, 2010 Hello to the community, i need help with some things. im using this code to change the pages with links in menu: <?php $str = $_GET['str']; if(strlen($str) && preg_match('/^[\-_a-z0-9]*$/i', $str)) { if(!include $str . ".html") { include "index.html"; } } else { include "index.html"; } ?> then in menus this: <a href="index.php?str=page_2">Page2</a> Now what code i need to add or change to get things on menus marked on which page are you atm? Page1 Page2 Page3 Page1 Page2 Page3 (when you are on page3) Quote Link to comment https://forums.phpfreaks.com/topic/188360-php-include-html-pages-and-marked-menus-help/ Share on other sites More sharing options...
MadTechie Posted January 13, 2010 Share Posted January 13, 2010 I guess you could do something like this <?php //Full page list $pages = array( "page_1"=>"Main Page", "page_2"=>"Page2", "page_3"=>"Page3", "page_4"=>"Page4", ); //Get Page selected $page = (empty($_GET['str']))?0:$_GET['str']; //Display links echo PageLinks($page,$pages); //check selected page is correct name format if(preg_match('/^[\-_a-z0-9]+$/i', $page)){ $file = "$page.html"; //check page exists if(file_exists($file)){ include($file); exit; } } //any faults display home page include "index.html"; function PageLinks($page, $pages){ $str = ""; foreach($pages as $k => $v){ if($page == $k){ $str .="<p><strong><a href=\"index.php?str=$k\">$v</a></strong></p>\n"; }else{ $str .="<p><a href=\"index.php?str=$k\">$v</a></p>\n"; } } return $str; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/188360-php-include-html-pages-and-marked-menus-help/#findComment-994388 Share on other sites More sharing options...
Lovac Posted January 13, 2010 Author Share Posted January 13, 2010 thx it works, can you help me out a bit more? i need to add class from .css to menu, how to do it? im php newbie Quote Link to comment https://forums.phpfreaks.com/topic/188360-php-include-html-pages-and-marked-menus-help/#findComment-994409 Share on other sites More sharing options...
MadTechie Posted January 13, 2010 Share Posted January 13, 2010 If you can post a HTML example of the selected page and unselected pages i could update it for you. basically your need to change if($page == $k){ $str .="<p><strong><a href=\"index.php?str=$k\">$v</a></strong></p>\n"; }else{ $str .="<p><a href=\"index.php?str=$k\">$v</a></p>\n"; } to something like this if($page == $k){ $str .="<p class=\"selected\"><strong><a href=\"index.php?str=$k\">$v</a></strong></p>\n"; }else{ $str .="<p class=\"unselected\"><a href=\"index.php?str=$k\">$v</a></p>\n"; } Quote Link to comment https://forums.phpfreaks.com/topic/188360-php-include-html-pages-and-marked-menus-help/#findComment-994460 Share on other sites More sharing options...
Lovac Posted January 13, 2010 Author Share Posted January 13, 2010 tried but look what happens: this is default menu: page1 page2 page3 page4 when you click on page2 for example it turns like this: page1 page2 page3 page3 but my problem is that until you click something on menu its like this, when you enter site its behaves like its allways on selected: page1 page2 page3 page4 Quote Link to comment https://forums.phpfreaks.com/topic/188360-php-include-html-pages-and-marked-menus-help/#findComment-994467 Share on other sites More sharing options...
MadTechie Posted January 13, 2010 Share Posted January 13, 2010 for a default page you can update the code //Get Page selected $page = (empty($_GET['str']))?0:$_GET['str']; to //Get Page selected $page = (empty($_GET['str']))?"page_1":$_GET['str']; that will make page_1 the default page. can you post the PageLinks function and I'll take a look Quote Link to comment https://forums.phpfreaks.com/topic/188360-php-include-html-pages-and-marked-menus-help/#findComment-994474 Share on other sites More sharing options...
Lovac Posted January 13, 2010 Author Share Posted January 13, 2010 hey hey, that worked. Thank you very much! edit: classes are not working in IE Quote Link to comment https://forums.phpfreaks.com/topic/188360-php-include-html-pages-and-marked-menus-help/#findComment-994485 Share on other sites More sharing options...
MadTechie Posted January 13, 2010 Share Posted January 13, 2010 Your welcome, if this is solved click solved (bottom left) (you can unsolve it if needed) also read the code and play around with it.. so you understand it, any questions i'm sure someone or myself will be happy help. Happy PHPing Quote Link to comment https://forums.phpfreaks.com/topic/188360-php-include-html-pages-and-marked-menus-help/#findComment-994487 Share on other sites More sharing options...
Lovac Posted January 13, 2010 Author Share Posted January 13, 2010 oh edit again, works, forgot to upload .css also..silly me works ill close it, thx Quote Link to comment https://forums.phpfreaks.com/topic/188360-php-include-html-pages-and-marked-menus-help/#findComment-994489 Share on other sites More sharing options...
MadTechie Posted January 13, 2010 Share Posted January 13, 2010 Can you supple more detail, as "not working" doesn't help much! However if its a CSS problem then a new thread in the CSS section would be better.. Quote Link to comment https://forums.phpfreaks.com/topic/188360-php-include-html-pages-and-marked-menus-help/#findComment-994494 Share on other sites More sharing options...
MadTechie Posted January 13, 2010 Share Posted January 13, 2010 LOL okay! Quote Link to comment https://forums.phpfreaks.com/topic/188360-php-include-html-pages-and-marked-menus-help/#findComment-994495 Share on other sites More sharing options...
Lovac Posted January 14, 2010 Author Share Posted January 14, 2010 hello, need more help please. not sure if you got my msg, but this is the problem now which i didnt noticed before: this is bottom of page which uses this php, its ok, you can scroll to the end of page where is copyright (i cuted it out on this pic) http://www.imagesforme.com/show.php/919785_botom1.jpg when using menu bottom of page is cutted of, finishing edged, copyright part and grey background, all are missing and cant scroll further then contents ends: http://www.imagesforme.com/show.php/919786_botom2.jpg Quote Link to comment https://forums.phpfreaks.com/topic/188360-php-include-html-pages-and-marked-menus-help/#findComment-994588 Share on other sites More sharing options...
MadTechie Posted January 14, 2010 Share Posted January 14, 2010 What browser are you using.. as it appears fine here.. i tested with a few browsers IE 8 (not 7 as stated in PM) FF 3.5, crome & Safari Quote Link to comment https://forums.phpfreaks.com/topic/188360-php-include-html-pages-and-marked-menus-help/#findComment-994638 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.