function get_pages($category_id) {
$result = $GLOBALS['db']->query("SELECT * FROM " . $GLOBALS['config']['db']['prefix'] . "pages WHERE category_id = $category_id AND status = 1 AND default_page = 0 ORDER BY title");
return fetch_array($result);
}
Could I use this do you think? - something like <?php getpages(3); { ?> … but I am unsure on how to write the getpage function like to call the data for the pages?
Bit lost lol - Cups, what you did looks good but I am not worried about pulling page id’s - I want to echo Content which will display in the category, and all the pages within that category
Nope - I want to write an if statement syaing " if you’re on category 3 then show:" (<?php if (category_id == 3) { ?> content here <?php } ?> … but I want all the pages within the category to also show the same content, rather than stating if page_id == 1, page_id == 2 and so on … its just so if I add a new page to a certain category I don’t have to go and manually update the page with the new page_id - I want it so all content within the specific category, also does the same for the pages within the category. I hope that makes sense
For a moment, forget you know PHP. No ifs, no ids, nothing - pretend you’re a client.
Show me the HTML (or the output), you would like to see for 2 pages in the same category and 2 pages in a different category. This will show us what changes, and what doesn’t.
For example:-
<h1>Sausages</h1>
<div class="page">
<h3>
Blugh, sausages are wierd!
</h3>
<p>
Some page content...
</p>
<a href="page.php?id=1">
Read more
</a>
</div>
<div class="page">
<h3>
Sausages, the food of the poor.
</h3>
<p>
Some page content...
</p>
<a href="page.php?id=2">
Read more
</a>
</div>
<h1>Bacon</h1>
<div class="page">
<h3>
We like Bacon, what about you?
</h3>
<p>
Some page content...
</p>
<a href="page.php?id=1">
Read more
</a>
</div>
<div class="page">
<h3>
Bacon rocks, mroe so with Brown Sauce.
</h3>
<p>
Some page content...
</p>
<a href="page.php?id=2">
Read more
</a>
</div>
Ok, in one category I want a menu relevant to that category shown, and in another category I want the menu relevant to that category shown… I have 3 menus.
First one is default to home page/ and sub pages such as contact/ about etc.
The other 2 menus are for Country 1, and County 2. - they of course have different pages relevant to the county (cities, museums etc).
Well every menu contains home and contact, and as long as you have set up your database so that Link 1 and Link 5 are associated with category 1, then something like this should do it:
How have you proved to yourself that get_pages(1) actually returns the values Link 1 and Link 5.
ps Naming variables soon becomes a critical issue, but so does naming your test data.
Using memorable test values, like Anthony’s Sausages and Bacon is a really good idea because it might make it obvious when we are getting conflicting problems, whereas Link 1 and Link 3 do not immediately throw into high relief any error you might have caused somewhere else.
It also makes it easier to explain, and provides a bit of fun too.
For the sake of argument lets say your 2 menus were Meat products and Vegetables?
So you keep a list of “pages” in a database, but you maintain a list of pages manually as well?
This is not the best idea, if your menus could be generated automatically by the computer.
Is that what you want to happen?
Otherwise just keep a straight html file with the menu written as an UL or whatever, and just include that file in the corresponding part of you tpl file.