Gossamer Forum
Home : Products : Gossamer Links : Discussions :

lowercase directory but uppercase category?

Quote Reply
lowercase directory but uppercase category?
I know this has been discussed in LinksSQL1.1 but I guessed it would be different as Alex re-wrote the code for LinksSQL2. Basically I want Links to create it's directories based off the category names but use lowercase rather than upper case.

Category:Actors and Actresses/Actresses
URL:.../actors_and_actresses/actresses

How can I do this? I don't want to make the category name's lowercase because it will look messy when people choose one in the add form. I took a look at the 'Setup > Build' area but it wasn't relevant to what I need.

Please help. Thanks in advance.

JeffB

Quote Reply
Re: lowercase directory but uppercase category? In reply to
How about the other way around - you can name the categories in lowercase (that will build the URL in lowercase) and display the category names in uppercase using CSS.
Simply use the following code to capitalize all H2 tags (or any other tag):

h2 {
text-transform: capitalize;
}

Hope this helps

Didi


Quote Reply
Re: lowercase directory but uppercase category? In reply to
I don't really want to use CSS sheets so this isn't really an option. I could have lower case categories and just use a CGI command to replace the first letter of each word. But how would I do this?

Quote Reply
Re: lowercase directory but uppercase category? In reply to
s/\b(\w)/\U$1/g;

That makes the first letter of each word uppercase. Do you want lowercase?

For lowercase you'd use....

lc($variable);

Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Quote Reply
Re: lowercase directory but uppercase category? In reply to
Would it best to create lowercase categories and change them to upper case when shown to the user or vice-a-versa? Also where would I put the code you gave in the previous thread?

Thanks.

Quote Reply
Re: lowercase directory but uppercase category? In reply to
Hi,

My category names are already in Upper Case so it would actually be better to convert the category name to lower case when building the directories. Surely we just need to put the "convert to lowercase" code just before Links creates and CHMODs the directories.

So, how can we convert all categories to lowercase for their URLs?

Jeffb

Quote Reply
Re: lowercase directory but uppercase category? In reply to
FWIW ... bad idea to hack Links SQL code like this.

New versions come out regularly, and 2.1 is on the way.

If you do, you need to keep a list of your changes, depending on Links to recognize the changed files is "risky" and still means a lot of work.

Also, many, many things were moved around inside links from 2.03 to 2.04. The external actions were relatively unchanged, but internally loads of things changed.

That said, the preferred way to make these changes in the templates is not the code for display purposes, using either a global function or a regular function (stuff it into the Utils.pm file)

In Reply To:
My category names are already in Upper Case so it would actually be better to convert the category name to lower case when building the directories.
Why you'd want to do this, I don't know. This seems like micro managing something that pulls attention from the real issues of site development.

That said, isn't that what the 'build_directory_field' field is for???

Just add a field and populate it with:

update Category set build_directory_field = lower(Name)

You'd need to rerun this every time you added a new category, or make sure you add the lower case name when you enter the record. To remind you, I'd add the field with MySQL Man, and put it as coming after Name, then go back to LinkSQL Admin, and resync the category table.



PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Plugins:http://LinkSQL.com/plugin
Quote Reply
Re: lowercase directory but uppercase category? In reply to
Pugdog,

Thanks for the help. The reason I was after this solution is because at the moment we have the directories being created with Upper Case characters in them and some users are getting 404's because their browsers convert everything to lower case. We thougt that if we changed everything to lower case then it would please everyone.

See the logic or should I just not bother?

JeffB

Quote Reply
Re: lowercase directory but uppercase category? In reply to
What browsers convert all the URL's to lower case??? In a Unix world, ie: Internet, this is not a good thing! It will only get worse, and worse with time! Are you sure that's the problem??

But the build_directory_field should work, if you want to pursue it.

PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Plugins:http://LinkSQL.com/plugin
Quote Reply
Re: lowercase directory but uppercase category? In reply to
I think I will forget this. I only had a couple of complaints and although it would look "neater" in some way to just have lowercase URLs, the effort out weighs the reward. Pugdog - any chance you can look at the numbered links mod?

JeffB

Quote Reply
Re: lowercase directory but uppercase category? In reply to
What numbered links mod?

PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Plugins:http://LinkSQL.com/plugin
Quote Reply
Re: lowercase directory but uppercase category? In reply to
Hi,

Sorry for not explaining. Here is the link (it's actually just a discussion at the moment)...

http://gossamer-threads.com/p/127425

JeffB

Quote Reply
Re: lowercase directory but uppercase category? In reply to
Hi Jeff,

If you are interetsed (or anyone else reading this thread), the steps would be:

1. Add a field to your category table called 'Directory'. Make it a CHAR of size 255.
2. Go to Setup->Build Options, and edit build_directory_field, set this to 'Directory'.

Now Links SQL will use that field for what the directory name should be. So when you add a category, you just need to enter in the directory name as well.

If you already have a lot of category and need to update them all to lowercase, use pugdog's SQL statement above.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: lowercase directory but uppercase category? In reply to
The reason I suggested using MySQLMan is that you can place the two fields near each other, so you don't forget to enter BOTH in the record. You could set the Directory field as "required" which would generate an error if not entered, but still not as nice as the visual cue of the two fields next to each other.

Using the "field position" in the Links editor, still causes field names to disappear from the admin templates :) So I try to do only what I really need to in the Links edit-field-properties sub menu. By Using MySQLMan, you get around this persistant bug/quirk.



PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Plugins:http://LinkSQL.com/plugin
Quote Reply
Re: lowercase directory but uppercase category? In reply to
I hacked my Links 2.0 Text Database the way you wanted it.
I had my Categories in upper and lower case, but wanted my directories to only be in lower case.

I added the command "lc ($dirs)" on three of four places and viola, fixed... Don't know if the script is the same in Links SQL, if it is, mail me and I'll try to help you: spiff_swipnet@hotmail.com

Quote Reply
Re: lowercase directory but uppercase category? In reply to
I hacked my Links 2.0 Text Database the way you wanted it.
I had my Categories in upper and lower case, but wanted my directories to only be in lower case.

I added the command "lc ($dirs)" on three of four places and viola, fixed... Don't know if the script is the same in Links SQL, if it is, mail me and I'll try to help you: spiff_swipnet@hotmail.com


Quote Reply
Re: [Alex] lowercase directory but uppercase category? In reply to
In Reply To:
Hi Jeff,

If you are interetsed (or anyone else reading this thread), the steps would be:

1. Add a field to your category table called 'Directory'. Make it a CHAR of size 255.
2. Go to Setup->Build Options, and edit build_directory_field, set this to 'Directory'.

Now Links SQL will use that field for what the directory name should be. So when you add a category, you just need to enter in the directory name as well.

If you already have a lot of category and need to update them all to lowercase, use pugdog's SQL statement above.

Cheers,

Alex

--
Gossamer Threads Inc.


I tried this last night and to my dismay it created the directories as absolute to the root instead of relative of the parent Category. For ex, if the Category was "Cars/Volkswagen" and Directory="vw", it created the physical directory as "/vw". Logically, I assumed that it would have created the directory relative to it's parent, e.g. "/Cars/vw". Imagine the nightmare if you had 100 subcats to "Cars" and decided to change "Cars" to "Automobiles". You would have to edit the Directory field for 100 diff records. Sure, you could use SQL, but the point is that the potential for error is tremendous.

If I had designed it, it would work as follows:

- if Directory IS NULL => create the physical dir in the Normal manner, i.e. use the Category Name and convert space to "_".

- if Directory IS NOT NULL => use the value for Directory, the path is relative to the parent Category

Example

1. Category = "Cars", Directory=NULL ==> /Cars/

2. Category = "Cars/Volkswagen", Directory="vw" ==> /Cars/vw/

3. Category = "Cars/Dodge Trucks", Directory=NULL ==> /Cars/Dodge_Trucks/

If you wanted to make the directory absolute to the root, you could specify "/" as the first char, e.g. "/vw"

Last edited by:

vicos2: Jan 9, 2003, 5:57 PM
Quote Reply
Re: [vicos2] lowercase directory but uppercase category? In reply to
In case this helps, Full_Name gives you the directory structure - I just joined my new field name onto the end of this.
Quote Reply
Re: [afinlr] lowercase directory but uppercase category? In reply to
Just finished a plugin, which can be deal with "Full_Name" to "directory name" conversion.
Can be modified to deal with capital-lowercase conversion.

You can check here for more info:
Webmaster33's under development or planned plugins

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [Alex] lowercase directory but uppercase category? In reply to
In Reply To:
Hi Jeff,

If you are interetsed (or anyone else reading this thread), the steps would be:

1. Add a field to your category table called 'Directory'. Make it a CHAR of size 255.
2. Go to Setup->Build Options, and edit build_directory_field, set this to 'Directory'.

Now Links SQL will use that field for what the directory name should be. So when you add a category, you just need to enter in the directory name as well.

If you already have a lot of category and need to update them all to lowercase, use pugdog's SQL statement above.

Cheers,

Alex

--
Gossamer Threads Inc.


I've added a field named DirName to the lsql_Category table and I've added DirName to the build_directory_field field in Setup > Build Options. When adding or modifying a category, DirName is not a field available for specifying the build name to be used. Can someone please advise changes that are needed to have that field display as part of the Category definition fields?

LSQL Version: 2.1.2

Thanks!
Quote Reply
Re: [Karen] lowercase directory but uppercase category? In reply to
Do you mean you added the field in mysqlman? If so, you'll need to resync the database to get it into the def file (admin->database->category->properties).
Quote Reply
Re: [afinlr] lowercase directory but uppercase category? In reply to
Thanks for the reply. I've been able to get the field displaying in the admin and it is working well. Just curious now whether someone could provide some insight. In the Categories table, there is a field named "Name" that displays in the admin when adding/modifying a Category. No problem there. There is also a field named "Full_Name" that is "hidden" (although specified to be a Text field) that is apparently getting its value from "Name". What is the purpose of "Full_Name"? How can Full_Name be displayed in the Add and Modify interface?

Essentially, I'm trying to figure out how to prevent having three fields with the same data for each category.

Name = My Category
Full_Name = My Category
DirName = my_category

Again, thanks for the reply. Much appreciated!
Quote Reply
Re: [Karen] lowercase directory but uppercase category? In reply to
Full Name should hold the value of the directory structure - like

transport/boats/rowing_boats

and Name would just be

rowing_boats

I'm not quite sure how this works when you use the Directory naming - mine is setup a bit strangely.