Any idea ? pls

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
crazytopu
Forum Contributor
Posts: 259
Joined: Fri Nov 07, 2003 12:43 pm
Location: London, UK
Contact:

Any idea ? pls

Post by crazytopu »

I am currently working with a basic content management system. Part of this job is to make sure that a completely non-technical person can add or remove and modify links, text etc. But there is a little problem and it's hard to explain the proble I am facing. So, lets give you an idea what I am trying to achive.

Lets assume, I have 5 divs and under each I have a list of bullet links drawn from the database table - "link". The link table has THE following structure:

ID int(5) auto increment
link varchar2(20)
div varchar2(10) /*here, div indicates the location of the page the links belong to*/
PRIMARY KEY ----------ID.

So, whenever you want to add a link to a div, you first go the admin panel and then go to the appropriate div (my home page and admin panel for the home page, have the exact same look but only there are some extra links on the admin panel, like add link, delete link.......I followed this style for all other pages in order to make the admin job easy for the non-tech guy), and under each div you can perform the tasks such as "add link", "deletelink" and "modify link". You add a link by typing up the link and the div id (where the link should belong to) and hit save. Next time you refresh your page, you find the link appeared under the div you specified. The hyperlinks are being created on-the-fly with the help of PHP.

So, the SQL command I used with this case was :

SELECT link FROM link WHERE DIV='1'
when I want to retrieve only those link which should appear on div1.
or DIV='2' when the links should appear on div2 and so on.

But I find this tricks pretty loose. The non-technical person is not meant to know what "div" is and would get confused when he needs to supply the div Id. But from my point of view I really need to store the information of which links should belong to which Div so I can query appropriately. If there is any better means that you guys knows of, please lend your generous support.

I had a clue as how to make the situation better, but yet it seems to lack some flexibility. As you know, each div on the home page and corresponding admin panel for the home page would have a heading - like - latest news, resources etc. I thought of letting the admin user to enter that heading instead of the div when they want to add up a link.


So in that case my query to retrieve all the links under the link "Latest IT NEWS" would be like:

SELECT link FROM link WHERE heading='Latest IT NEWS';

But, what if the admin user wishes to change the heading of the div, lets say from "Latest IT NEWS" to just "IT NEWS"?

How would I reflect this changes into my query statement which has bee hard-coded?

Could i use somethink like,

SELECT link FROM link WHERE heading_id='1';

and add an extra column to my link table : heading_id (this id would be used here as the foreign key and whenever user changes a heading it will update the "heading" in heading table (heading_id would the primary key here) )


this page contains the home page: http://crazytopu.hollosite.com/test/

The admin panel would look same except those administrative links.


Also, there is one more question: is it really a good idea to redundant the links for each div? [I just made those links (add link, delete link)appear on each div so the novice user knows where he wants to add a link and where to expect them to appear after they save it].

Any idea, tip or suggestion are highly appreciated.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

have a database table of div details (like name and an ID, at least). When adding a new link, select all the available divs from this table. Make a drop-down list that maps the name to its ID.
Post Reply