Always keep learning, that’s my motto. My grandfather was my
inspiration on that front, just kept reinventing himself until he was
93, I lost track of how many careers he enjoyed.
On Feb 17, 2010, at 12:43 PM, jan smoot wrote:
Walt,
Thanks so much for your reply. I am an old dog learning new tricks,
so agree “… working way too hard…” Sorry if my questions seem so
basic, just striving to get clarity and hope it will benefit others.
Thing 1. I accept your suggestion to use Prototype (not experienced
enough to evaluate choosing one) Just to verify the gritty details,
Do I:
a) download the library from prototype.js (version 1.61 seems to be
most recent)
b) upload to my site
c) in html page markup, include
d) how do I “add this code to one of the Function Body dialogs”?
I was referring to you using the Protaculous Action to both link up
the Prototype.js library to your page as well as to create an
unobtrusive listener function in the head of your page where you could
add the function you need. If you install the Action and apply it to
your test page, you’ll see what I mean pretty clearly.
e) You say I need to “add an ID to your months picker”. Not sure
what this mean. Are you referencing my getMail(month) function?
Freeway, bless its little knees, refuses to add IDs to form elements.
This plays badly with Prototype, which wants to see an ID on anything
it messes with.
Click once on your months picker, choose Item / Extended from the main
menu, and then make sure you have selected the form element tab in the
resulting dialog (not the div or its style, in the case of a layered
form element). In this dialog, press New, then in the Name field enter
‘id’ (without quotes) and in the Value field enter ‘months’ (without
quotes).
Now if you have drawn this form element as a layered object, go back
and make sure that the layer it’s on is NOT also named months. Call it
something else. Two items cannot share an ID, and Freeway will not
check what you enter in the Extended dialog while publishing to see if
there’s a conflict. It will check to see if there are any other
elements on the page with the same name in the regular Name field in
the Inspector.
Thing 2. About the DB connection…thanks for the code. You say
“this is get_mail.php” so this should replace my get_mysqlmail.php?
Could not see/find it on the github link, so I will copy…
The GitHub link gets you the ORM library I use and maintain –
MyActiveRecord. This was started by Oxford native Jake Grimley in
2006, and I’ve been shepherding its further development since late
2008. This library will allow you to build everything from a simple
address book to the most elaborate and interrelated web application
without needing to busy yourself with all the plumbing.
The code fragment I wrote in my last post was the entirety of the code
you need for your Ajax endpoint page. 12 lines of code including
comments, and you’re done. Put all that in a text file, top and tail
it with <?php ?> and save it as whatever filename you like. Make sure
you put the same filename in the JavaScript code, and you’re done.
a) You suggest I learn an ORM. Again, can you suggest something more
specific?
I meant MyActiveRecord, or one of the many equivalents out there.
Google ‘php mysql orm’ for page after page of possibilities. Anything
that puts a shinier face on MySQL is a good thing. I would go nuts if
I had to type mysql_connect(…) over and over on every page.
b) My data base only has one entry per month (all the mail for the
mont), which I keyed to the first of the month.
Aha. I see. If you stored them each with the datetime they were sent/
posted, you would be able to sort them and display them more
atomically. But if you don’t need it, it’s just more work. Do you mean
you cram all of the messages for the month together in the same text
field, or that you tag each message from a given month with the same
date – the beginning of the month?
c) I will change my mysql column names, Date and Mail, to fandate
and fanmail for clarity.
d) About the return values. In this simplified example, I am just
trying to have the fanmail shown in a div, but in on our site, it
will be in a scrollbox.
Then I would use an unordered list or just P tags for this, or if you
want everything to line up in columns, you could make a simple table.
The tags you’ve created will work because browsers ignore tags they
don’t understand and just show the contents. If you note, I encoded
your tagnames’ angle brackets so they would show along with the
content. But I think you probably want something like this:
<table cellspacing="0" id="mailTable">
<tr><th>date</th><th>mail</th></tr>
<?php
foreach(MyActiveRecord::FindAll('archive', $sql) as $message){
print '<tr><td>' . $message->h('Date') . '</td>
<td>' . $message->h('Mail') . '</td></tr>';
}
?>
</table>
And that will get you a nice layout that you can further style with CSS.
e) About htmlspecialcharacters, we vet the contents of the fanmail,
so not sure this is necessary for this ap, but understand your
suggestion.
User-generated content should always be cleaned of anything that is
considered a control character, like angle brackets, ampersands, etc.
It’s not just a case of wanting your page to be valid (of course you
do) but also what if someone types in the middle of a message
– does that cause the page to stop dead bang right at that moment? Of
course it does.
Thing 3. Yes, I do want something in the display scroll area upon
first load, just had not address that issue yet. Will study your
code to see how to use with a scroll box.
If you click on your DIV where you are going to show the posts, and
change the Overflow setting in the Inspector from Visible to Auto, you
will get your scroll area for free, and this code will just work.
Can’t tell you how much your input helps us lowly Freeway
implementers! Have been working with a great designer for a few
years doing some nice work, but want to offer more expanded
functionality within the Freeway development context. Wish Freeway
did more to help: better templates, tutorials and expanded
documentation. You are a life saver Walt. I told my designer, “there
is a god and his name is walt!”
Whoa, there. I’m not a god, I’m standing on the shoulders of clever
giants, as a frequent poster on the Prototype list has put it in his
signature. Everyone starts somewhere, and I started at the amoeba
stage back in 1997 with my first commercial site (wrote my first page
in 1995, in Claris HomePage or similar). My initial work product was
laughably crude, but then so was everyone else’s – remember Netscape
1? FreewayTalk was an important part of my learning, and continues to
be. I have had at least as much help from the list as I have given
back. Keep doing this stuff long enough, and sure enough you start to
remember some of it…
Walter
Jan
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options