Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Add Table to DB and Link it to Category

Quote Reply
Add Table to DB and Link it to Category
Hello,
I need to add a table with 20 fields in it to describe everything about an image (image name, title, size, length, width, padding, borders, thumbnaile.....etc.... ); then, I need to call a record from the new table when I add/modif a category from the admin.
So, I want to add one field to Categories table to call the image record something like (image_record: 234323) .. so I can use that image and display it when displying the category and subcategory???
Any idea how to do that?
Thank you in advance...
Mark
Quote Reply
Re: [Mark2] Add Table to DB and Link it to Category In reply to
Hi Mark,

I think that work. Just create a similar global at this url . You can just replace the table "Cateogry" or "Links" with your new added table name and $ID with your image_record value.

Cheers,



Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Add Table to DB and Link it to Category In reply to
Thank you,
Do you mean that I can add any table to the DB and call records from it (within LinksSQL templates) without establishing connection! as I need to add seven more tables with each one has different stuff... but I want to be able to use them in a category/subcategory or links .... but sometimes I need to link/nest tables to be able to reference the rest of the "Links" or the rest of "category" from the new tables??? and this is the issue...
thank you in advance...
Mark
Quote Reply
Re: [Mark2] Add Table to DB and Link it to Category In reply to
When creating a new table, making a def file for it, that will work with any global. Of course, we need to load these new one by global or plugin because glinks is just loads its built-in tables like Links, Category, etc.

Cheers,

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Add Table to DB and Link it to Category In reply to
Thanks agin Dat...
I am still wondering if I add new new tables using mySQLManager, will the tables appear in the "Database" section in LinksSQL in the pull-down menu on the left so I can easly modify them through "properties"....

and Regarding the def files as you've mentioned... where is that and do I need to copy it somewhere so i can start using the new table fields in the templates...
thanks again for your time..
Mark
Quote Reply
Re: [Mark2] Add Table to DB and Link it to Category In reply to
You should edit the templates/admin/db_nav.html by adding a revelant row below the link '<option>Reviews</option>'

The def file should be put in admin/defs. Once it is created and you are on the 'properties' page, just click on the "Resync" to make sure that the def and the table's fields are the same.

Cheers,

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Add Table to DB and Link it to Category In reply to
I created a new glinks_images_table table and edited templates/admin/db_nav.html using FileMan that comes with Links.
I added the name in the options: <option>images_table</option> and all done in TEXT MODE using FileMan...
but is seems the whole db_nav.html file get corruppted as the FileMan editor removed the JS script from the file when I swiched... back and forth.. so now I have to reinstall links or get a zipped file from somewhere....
another thing... where is the new table def file so I can add it to admin/defs as you have suggestted...
and thanks always for all your help... well appreciated.
Mark
Quote Reply
Re: [Mark2] Add Table to DB and Link it to Category In reply to
Hi Mark,

You shoud edit the file with a text editor then update it.

The def file should be created manually by you. The simpiest way is copy an existings one like Links.def as "your new table name".def. Then select the table name and properties box and go. When the page is showing, there is a "REsync" link at the bottom. Just click on that link and glinks will update your def file.

Hope that helps

Cheers,

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Add Table to DB and Link it to Category In reply to
Thanks very much Dat... your assistance was very valueable....
Also.. I used the script in this thread to create def files.. it was very practical...
http://www.gossamer-threads.com/...orum.cgi?post=254807
and also.. I reinstalled linkSQL to recover the corruppted file db_nav.html so it works just fine..
thanks again for your help
Mark
Quote Reply
Re: [tandat] Add Table to DB and Link it to Category In reply to
Hi Dat....
Me again... I posted several threads about the use of the Db and did not get an answer yet ...
I was wondering if there is a way to display a field from the new table in the Add Category Form...

The new table called car_clients and all dithe def files for it and sync'ed them using LinksSQL ..

First field is the client_id = Primary
then second is: client_name = Index
Address: Txt....etc.
then many other fields...

Now, I want to pull the 'client_name' from car_clients table and display it as a pull-down menu when I adding a record to another table (Category) in the same DB. Mean pre-populate a field in "Category" table from another filed in another table... where should I make the change....
I found a thread: http://www.codingforums.com/showthread.php?t=63636 that says something close to what I am doing.. but not exactly...

Thank you again for your help...
Mark
Quote Reply
Re: [tandat] Add Table to DB and Link it to Category In reply to
It seems that you want to use this in admin page?

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Add Table to DB and Link it to Category In reply to
Yes! exactly, I want the change in the admin side, so when I click on "Add a Link" or "Modify a Link", a pull-down menu with the name of the clients (from car_clients table) should appear in the Add/Modify Form (instead of he extra field that I added to Links Table (the_client) ....

Thank you in advance for your help
Mark
Quote Reply
Re: [Mark2] Add Table to DB and Link it to Category In reply to
This should need a small plugin to hook into that process OR modify the Links::HTML::Links.pm directly because we cannot use template for this case in admin

Just try the below. You may change the table name and field name and form

Cheers,

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Add Table to DB and Link it to Category In reply to
Thanks much Dat...
I've tried the plug in but got the follwoing error on execution:
Code:


A fatal error has occured:
GT::SQL::Table (5884): Unknown method 'fetchrow_allhashref' called at /path-to-the-admin/admin/Plugins/Admin_AddForm.pm line 49.

Please enable debugging in setup for more details.


not sure what is the problem.. soI removed the plugin... any idea...

thank you again...
Mark
Quote Reply
Re: [Mark2] Add Table to DB and Link it to Category In reply to
Hi Mark,

There was an incorrect method. It should be correct now.

Cheers,

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Add Table to DB and Link it to Category In reply to
Thanks as always Dat,
Your code works just fine... it was just missing the open braket "<" for the "select". After I added it I say the drop down list but ABOVE the form (means above when I click Add>Link.. I see the "client:" pull-down menu above the table that contain the rest of the form fields (above "Title" field outside the table).
Now, these observations:

1- can the client field (pulldown menu) be displayed somewhere inside the form table? so it becomes like any other field in the form... you can search the links using it?

2- when I click on "Links > Search" I see The_Client field (Client) however, this field can not be used to search and does not show this field as part of the search results.

What I am trying to do is to have the_client field (client:) shows as part of the rest of the fields fields... (some type of mapping or left joined call to pull the right client name for the right record).
like if I go to LINKS > Modify record with ID (234)... I want to see the_client (client:) field as a READ-ONLY field with the originally selected client from the drop-down menu (not show all the options in the select box), instead just show the one that was already selected when I added 234.

Thank you again...
Mark
Quote Reply
Re: [tandat] Add Table to DB and Link it to Category In reply to
Hello Dat,...
Have you had a chance to look at my last reply if you have sometime, then your blugin can be very effecient.
Thank you much as always
Mark
Quote Reply
Re: [Mark2] Add Table to DB and Link it to Category In reply to
Hi Mark,

I saw your message but I have no time at the moment to enhance this. I hope there will some free time within next few days.

Cheers,

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Add Table to DB and Link it to Category In reply to
Hello,
i tried different ways, but i dont get the new table to the database section in the dropdown menu.

-I copied an existent table and renamed this.
-Then i copied the def file for the origin table and renamed this with
newtablename.def
-No new table appears in the database section

Then i made from the Mysql settings section:
Load table info from an existing set of tables (or resync the def files if you have changed your defs manually)

But still there appears nothing.

Is it possible that this is a path problem, cause also an ajax feature in Sqllinks doesn t work ?

Best regards
manne


http://www.edelsteine.de
Quote Reply
Re: [manne] Add Table to DB and Link it to Category In reply to
I forget to say that i am trying only to bring a new table in contact to LinksSQL.

If there is somebody who has similar experiences and can help it would be fine.


Hello,
i tried different ways, but i dont get the new table to the database section in the dropdown menu.

-I copied an existent table and renamed this.
-Then i copied the def file for the origin table and renamed this with
newtablename.def
-No new table appears in the database section

Then i made from the Mysql settings section:
Load table info from an existing set of tables (or resync the def files if you have changed your defs manually)
and also i resynced with
http://www.domainname.de/cgi-bin/admin/admin.cgi?db=TABELLENNAME&do=editor_update_def

But still there appears nothing in the database section.

IT works now
I forgot to change the
db_nav.html admin teplate
i added now the option
<option>Products</option>

after
<option>Category</option>
<option>Links</option>
<option>Users</option>
<option>Reviews</option>


Thanks and best regards
manne


http://www.edelsteine.de

Last edited by:

manne: Mar 16, 2007, 2:35 AM