4Hero Posted March 3, 2006 Posted March 3, 2006 Guys, I have a bit of a dilemma. I'm currently building a site and am using php include to call content from another page, I know very little about php, and I normally only write css and xhtml. The question I have is: Is it possible to only display certain DIV's from the php page I am including? For example, I am using < ?php include ("stuff.php"); ? >, in the home page (index.php) of a site, to call the following content (obviously there are no spaces between the tags in the real code): this is what's in stuff.php: < div id="thumb" >< a href="#"><img src="thumb.jpg" / >< /a >< /div > < div id="photo" >< img src="photo.jpg" / >< /div > < p id="shortDesc" >A really short desciption explaining what thumb.jpg is.< /p > < p id="londDesc" >An Extremely long description describing in great detail what image.jpg is, this description is huge and goes on forever.< /p > But all I want to display on index.php is the "thumb" and "shortDesc" if you catch my drift. Is this possible, or is there an alternative method (except mysql)? I am a web designer, not a developer, so any help would be hugely appreciated, I'll even buy you a pint at the next meet if you are there [y]
IanJ Posted March 3, 2006 Posted March 3, 2006 I might be wrong but i don't think you can be selective on which code you want to use from stuff.php you can only include everything within it. (I am only a Business Analyst who tinkers in code though)
4Hero Posted March 3, 2006 Author Posted March 3, 2006 Thanks Ian, I think I am barking up the wrong tree here with php. I have browsed the web, and found now't, which kinda makes me think it's not possible [] I could have separate files I suppose with each of the div's, and call them one by one, but this will get messy through time. Cheers for answering, Neil.
4Hero Posted March 3, 2006 Author Posted March 3, 2006 I have spent hours trying to figure this out, without a break, go make a coffee, and within 30 seconds, EUREEKA I have the answer [] I can use display:none in the css to hide whatever div's I like on each page!!! Easy as that... It's not the perfect solution, as all the code is still loaded when you visit the page (it just doesn't show to you and me). Chuffed [y]
IanJ Posted March 3, 2006 Posted March 3, 2006 Nice work...give yourself a payrise [] What do i know...i'm being shipped off to the colonies tomorrow (Not that i'm counting down the hours!)
4Hero Posted March 3, 2006 Author Posted March 3, 2006 Nice work...give yourself a payrise [] What do i know...i'm being shipped off to the colonies tomorrow (Not that i'm counting down the hours!) Thanks Ian, I might just do that! What are you off to the colonies for? Work? Fancy a chum []
IanJ Posted March 3, 2006 Posted March 3, 2006 Yip, off to work for our Australia/New Zealand division (I work for a little IT company called Oracle). Got a 4 year visa, so going to play it by ear.
4Hero Posted March 3, 2006 Author Posted March 3, 2006 I am sure I have heard Oracle somewhere before, can't think where though [] Have a great time mate, you lucky man..
IanJ Posted March 3, 2006 Posted March 3, 2006 Have a great time mate, you lucky man.. I try my best! [H]
Highlander68000 Posted March 3, 2006 Posted March 3, 2006 It is more than possible. Not difficult, but maybe long winded. Is the list of stuff you want to display long?
4Hero Posted March 3, 2006 Author Posted March 3, 2006 it's not long, here's a screenshot of what I want to display on the homepage: but stuff.php contains loads more description. Basically, I am working on an estate agents site. He doesn't want to fork out $$$ on a content management system, and I am trying to make it as easy as possible for him to maintin the property page. The actual property page (stuff.php, for example), contains the whole property schedule details, but I would like certain parts to be shown on the homepage automatically. Hopefully that makes sense. edited to say: The actual property page (stuff.php) will contain around 40 properties max, but I only want the latest 2 to be shown on the homepage Any help would be excellent!
st3ph3n Posted March 4, 2006 Posted March 4, 2006 Hmmm, I can think of a lot better ways to do this mate. You could use some fancy AJAX and load the property data out of XML. Very modern. Ummm, I'm assuming stuff.php basically pulls a recordset out of a database and loops through each record to output the properties? If so then take a copy of it and only do the first 2 iterations of the loop. PHP is very easy to use if you can script/program to any degree. Have a look at the RB map in my sig. Check the code. That's some AJAX to dynamically load the pointers out of an XML file. Blatantly stolen from somewhere else of course!
4Hero Posted March 4, 2006 Author Posted March 4, 2006 Thanks mate, I am a designer, not a developer. I only write xhtml and css, but specialise in web site accessibility. I normally use developers to work on this kind of stuff, but due to my clients budget, this is not allowed []
Neofox Posted March 4, 2006 Posted March 4, 2006 It is possible to use the include call to bring in the page as a string then search through that string looking for a certain reference in your stuff.php page the grab just that and define it to certain variables saving you having to load the whole php page into your index page
4Hero Posted March 4, 2006 Author Posted March 4, 2006 problem solved! Many, many thanks to Jon (Highlander68000) for solving my dilemma [] What an effort he has put into this. And it was all done using php! Thanks Jon!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now