Forum OpenACS Q&A: Getting current News items on Home Page!

Good Afternoon,

I've searched the message base and finding nothing or what I did find was difficult for my to understand, here is my issue:

I am trying to display the article titles from my news page in a table cell on my index.html page. I understand this can be done via a .tcl or .adp page, but nowhere can I find exactly what is required when constructing an .adp or .tcl page.

If anyone has accomplished this, could you send or provide your code. I think after this one, I'll be able to figure out how to embed further functionality throughout my site.

Thanks,

Collapse
Posted by Stan Kaufman on
IMHO, the best way to bootstrap your OpenACS development efforts is to read through the code in the vanilla install.

Look at /news/index.tcl and see how the DB search is constructed and built into the html. Extract what you want of that into a /index.tcl home page (or /index.adp if you prefer that--I personally prefer to build all pages as .tcl and then send 'em to a template) along with the other stuff you want. In this fashion, you can embed various modules (news, bboard stuff, etc etc) into any page you want.

The existing code (in 3.2.5) is rather confusing and not optimally documented, but that just means that when you figure it out, you'll really understand it!

HTH.

Collapse
Posted by Gilbert Price on
Thanks Stan, I figured I'd be doing this anyway, just wanted to see if there was a possibility of getting a jump start 😊 . I'll probably print out all the index pages and start looking for the common components.

Thanks again...

Collapse
Posted by S. Y. on
Disclaimer: I haven't touched ACS Classic nor OpenACS in about 18 months.

The intranet module has/had some examples of generating a page with multiple elements including news, etc. in table cells. Reading the documentation and the source code are places to start. Good luck.

Collapse
Posted by Scott Mc Williams on
Gilbert, James Shannon created a module called "Chunks" that I believe is in the latest versions of OpenACS. It does exactly what you want. You can see it in action at www.sv2s.com.

Scott
Collapse
Posted by Gilbert Price on
Thanks Sean and Scott,

Chunks looks exactly like what I want, I guess my problem with the incorporation of dynamic data with HTML is I'm really a "newbie" when it comes to the use of TCL and the entire ACS system. While I am proficient with the use of php and HTML, the ACS way is different. I'm used to the HTML being in plain sight with the php embedded into the basic HTML page. The .tcl page looks completely different, in fact it looks like a large TCL script with a little HTML embedded into it.

It's hard to follow the index.tcl page from the Intranet module because of the interaction with all the extra files in many different modules; some of which are not in the document root.

I think when I get this figured out, I'll have to document the process to build a .tcl page and post it.

When I get back to work I'm going to print out all the pages in the OpenACS 3.2.5 distro and see what I can learn.

On a side note, while "chunks" looks like what I want, and the referenced site does have the functions I'm looking for on the front page, how would I actually implement it? I know I just can't cut the TCL section I want and paste it into the table cell I need.

Oh well, this is a problem for another day...

Thanks all,

Collapse
Posted by S. Y. on
Chunks looks exactly like what I want, I guess my problem with the incorporation of dynamic data with HTML is I'm really a "newbie" when it comes to the use of TCL and the entire ACS system. While I am proficient with the use of php and HTML, the ACS way is different. I'm used to the HTML being in plain sight with the php embedded into the basic HTML page. The .tcl page looks completely different, in fact it looks like a large TCL script with a little HTML embedded into it.

It's hard to follow the index.tcl page from the Intranet module because of the interaction with all the extra files in many different modules; some of which are not in the document root.

There is a significant, non-trivial learning curve in using ACS Classic and OpenACS. That's the way it is. There are certainly other alternatives (Zope, PHP, ColdFusion, Vignette, Slashcode, whatever). You will probably not be building photo.nets in your first week.

When I get back to work I'm going to print out all the pages in the OpenACS 3.2.5 distro and see what I can learn.

That's a lot of pages and Classic ACS/OpenACS are heavily dependent on things like preloaded Tcl procs, etc. If you choose to take this avenue, don't forget to print out all of the SQL that builds all the PostgreSQL tables. The data model is very important.

I don't know how you've decided how you are going to read all those pages. At least with the ACS Classic, documentation has ranged wildly from terse "Look at the source code" to the ACS version of War and Peace. I started diddling with the ACS in late 1998 and I can't imagine trying to print out Classic ACS's source + docs and trying to read it linearly. But that's just me. (I have no idea if OpenACS is markedly easier to read.)

You might be better off carefully studying relatively simple modules (I dunno: news, press, maybe faq).

ArsDigita used to have 3-week bootcamps with 3-5 problem sets. Depending on your learning style, you might be better off doing the psets first before tackling your own custom module, especially since you admitted to being an ACS/OpenACS/Tcl newbie. If you haven't read it, http://www.arsdigita.com/books/panda is still relevant. Buy Brent Welch's Tcl/Tk book; the first few chapters of the Tcl stuff should give you a good start.

I mentioned intranet/index.tcl because it's actually a good starting point. Make a backup copy (cp index.tcl index-orig.tcl) and hack down the page until it only has two dynamically generated elements. By dumbing down the page to this level, the code should be relatively easy to read. The ACS is so replete with code of different complexity and different quality (both in code and documentation), it's probably one of the best places from which to start.

Good luck.

Collapse
Posted by Gilbert Price on
Thanks Sean,

You've been very helpful, I purchased Phil's 1st book in 1998 and then the improved/expanded reprint when it came out. I originally wanted to do the ACS thing, but Oracle is just so expensive and I really can't afford it for my own personal site, hence the past 2 years learning Apache/php/MySQL (LAMPS).

When I found OpenACS, I leaped and recently set up the server and OpenACS. Your right about the steep learning curve, I'll print out everything and then read it in a non-linear fashion. I've already got all the SQL printed.

Welch's book is in my library, I'll dust it off in the morning and give it a go again.

I'd love to do a Boot Camp, but with 2 small kids, I can't travel right now. I'll try the home study course if aD still does that...

Your advice about the index.tcl in the Intranet module is right on, I hadn't thought of doing that, I was trying to cut a piece of it for inclusion into my current index page.

I've got alot to learn, maybe with help from you and others I'll actually have a presentable web service someday...

Thanks,

Collapse
Posted by Matthew Terenzio on
Here is an example of a page I am working on. I am no Tcl wizard, yet I managed to cobble together some code from other pages. Sort of Cave-man style but it works. Notice the ns_write "" Gilbert, which will will do just that and write everything between the quotes it to the document. You can use it to add HTML to the page in between(or around) the tcl code. By looking at the code and at the web page, you can see how I constructed it. The ad_header adds the beginning HTML tags. The ad_footer closes the HTML page. You'll see some tags which account for some missing HTML. I created these as an easy way to add HTML code I use a lot. Like a poor man's template. For more on how those work look HERE

One warning, the code will probably be available, but the web page may go down. Its being served by DSL and my provider went out of business (AGAIN!)

Here is the web page Page

Here is the code for the page in a text fileCode
Collapse
Posted by S. Y. on

Yes, I should have mentioned home study; that's what I meant. I think aD cut back on the 3-week boot camps since it was hard for people to give up that much time, especially people with jobs, lives, etc. Philip (that's his name, not "Phil" or "philg") used his own course at MIT as a little farm and started boot camps partly because he couldn't harvest enough ACS-qualified programmers out of his own little garden. 3-week boot camp was the initial incarnation, but almost nobody can/will give up that much time. No need to apologize about putting your family first.

Other good places to look for simple Tcl/ADP code: nsopenssl-tests.adp (in Scott Goodwin's nsopenssl code), maybe markd's aD Oracle driver tests, nstelemetry.adp (in the AOLserver source code), and simple example stuff in the AOLserver documentation. You can also try non-ACS specific stuff like http://www.webho.com/WealthClock.

After messing around with a little bit of Tcl, you'll find some of the quirks about inserting text, escaping special characters, dealing with math/regexp/variables/whatever, etc. Make some trivial changes, then try something a little more complicated.

Don't give up: Remember that the OpenACS needs enthusiastic newcomers like you!

Collapse
Posted by Gilbert Price on
Thanks Matthew and Sean,

The examples of your site are great for getting me started, by seeing the TCL source and comparing with the saved html, I've already got a better idea about what I need to do, looks like I'm going to have to get more imaginative in my visualization of the page as I develope the .tcl code. Thank's again for the examples, btw the site looks good!

Sean, thanks for the correction, I've read Philip's comments about those who don't use his name correctly, I definately don't want to get on his bad side.

I'll check out those other examples you mentioned. I'll get started on the psets this weekend (should be a couple of months worth of work, with my schedule).

Don't worry, I'm committed to OpenACS, the overall system offers so much value, and all it costs is a little time to learn a few more skills that add value to me and ultimately will allow me to add to the OpenACS community at large.

Thanks all, I'm off to bed...

Collapse
Posted by S. Y. on

One more response tonight from me: Philip is probably rather used to people calling him the wrong thing nowadays. In his complaints, Philip is usually railing over inane/stupid questions (in his opinion); if you make a smart argument, but still use the wrong name, he often ignores it. If you are lame and stupid and you happen to use the wrong moniker, well, all hell can break loose. Heck, we're all human and people have bad days.

My brain is puny and weak so I tend to separate the UI/HTML issues (stuff like Excite- or Yahoo-style nested tables or style sheets) from the SQL/dynamically generated stuff. Templating is beyond my capacity and I don't worry too much about fonts. I create the brain-dead HTML templates and play around with the Tcl/ADP stuff separately. Only after both things are working well independently will I try incorporating things together.

If I have a total brain fade, I sometimes wrap output in PRE tags (GIGO = Garbage In, Garbage Out) or try to echo variables that I think I've declared. That's often good enough to debug nasty HTML coding or my own crummy programming - at least for me. By acknowledging my own stupidity, it's easier for me to break down complex problems (at least in my mind) into a series of individual, discrete, relatively simple tasks. I know this pathetic for some of the hotshot programmers out there, but that's the way I face many technical issues.

Collapse
Posted by Dave Bauer on
You might be interested in my short introduction to how a tcl page is contructed. http://www.thedesignexperience.org/openacs/
Collapse
Posted by Rodger Donaldson on
You mentioned being confused by the use of .tcl pages; while it won't necessarily help you learn the OpenACS API per se, bear in mind AOLServer has ADPs, which allow mixing of code and HTML, just as you're used to with PHP.

Once you've started to get a feel for which procs, eg, check authentication or unroll news items from the DB, you can start using them in an ADP framework if that makes you more comfortable.

Gilbert, sorry I should have posted the code up before. Here's what I have on that home page for News:

[reiterate_through_chunk $db news "< a href="/news/item.tcl?scope=public&news_item_id=$news_item_id">$title
< br>$pretty_release_date< br>$body (< a href="/news/item.tcl?scope=public&news_item_id=$news_item_id">Read more)
< br>< br clear=all>"]
Here's Events (Calendar):

[reiterate_through_chunk $db calendar "< a href="/calendar/item.tcl?scope=public&calendar_id=$calendar_id">$title
< br>$pretty_start_date (< a href="$calendar_link">Get More Info)
< br>< br>"]
Forums (bboard):

[reiterate_through_chunk $db threads "< a href="$msg_link">$one_line
< br>  $count recent messages in
< br>  $topic



"]
and Classifieds (GC):

[reiterate_through_chunk $db recent_classifieds "< a href="$classified_ad_link">$one_line
< br>< br>"]
Note, get rid of the spaces after the "<" signs in the anchor tags and line breaks.

As you can see I'm using the heck out of Chunks. Although, it seems to not be updating everything like it should throughout the day. Sometimes I need to restart the server. If anyone fixes that, let me know!

Thanks,
Scott
Collapse
Posted by Jerry Asher on
Chunks' default behavior is to memoize everything on a two hour refresh. If you want to update it on a more frequent interval, you should be able to do this by setting parameters in your parameters/ad.tcl The following should set chunks to expire information once it is an hour old.
ns_section ns/server/${server}/acs/chunks
ns_param  newscachelength         3600
ns_param  bboardcachelength       3600
ns_param  eventscachelength       3600
ns_param  classifiedscachelength  3600
ns_param  auctionscachelength     3600
Collapse
Posted by Gilbert Price on
Sean, Dave, Roger, Scott, and Jerry,

Profuse thanks, (Sean) your tips about coding are going to be a big help, I've got all this php/MySQL stuff floating around, and I see I'm going to have to get better at coding HTML by hand, Dreamweaver doesn't do TCL/ADP 😊...

(Dave) You page is going to be a great help, thanks for pointing it out to me, I realized I already had your site bookmarked from another post you had made, but I didn't realize you had this page. Guess it pays to browse an entire site rather than just the home and one other page. Thanks again...

(Roger) Thanks for the info, I'll grab the AOLServer docs and read up on ADP's. Food for thought, and definately another skill to add to my bag...Thanks...

(Scott) Thanks for the code, seeing how you've implemented chunks and now with the code it's starting to make sense. I found the html file that explains chunks but seeing it actually used really makes a difference. Thanks...

(Jerry) Thanks for the clarification, while you weren't replying to me directly, nontheless it will help me also. By the way, I really like your site, the muted background images really make it special and gives it that professional touch.

All, thanks for your help, I'll be diving into all the suggestions and when I've got something to show in a few weeks I'll post it here and maybe you'll have the time to give me a little feedback...

Thanks,

Collapse
Posted by Gilbert Price on
Good Evening,

<p>I'm trying to get the "chunks" resources to work, my ad.ini or more specifically (defaultacs.tcl) file had no entries for the "chunks" procedures. I added the following to my file:

<pre>ns_section ns/server/${server}/acs/chunks

        ns_param NewsCacheLength=3600
        ns_param MaxNews=3
        ns_param MaxNewsBodyLength=120

        ns_param BboardCacheLength=3600
        ns_param MaxBboardThreads=5
        ns_param MaxMsgBodyLength=120
        ns_param CountOldMessages=10

        ns_param EventsCacheLength=3600
        ns_param MaxEvents=5
        ns_param MaxEventBodyLength=120

        ns_param ClassifiedsCacheLength=3600
        ns_param MaxAds=5

        ns_param AuctionsCacheLength=3600
        ns_param MaxAuctions=5
        ns_param CountOldBids=10</pre>

<p>When I restart my aolserver, it just don't go - When I remove the above, it starts normally. No errors are in my .log file. If you've got any ideas, I'm open to all suggestions!

<p>Thanks,

Collapse
Posted by Jerry Asher on
I suspect it's the extraneous equal signs that are causing your problems.
Collapse
Posted by Gilbert Price on
Thanks Jerry, that was it...
Collapse
Posted by Jun Yamog on
Hi Guys,

I have almost the same problem with Gilbert.  Although a little
different.  I am now using OpenACS 4.x for this site.

Same issue on the home page.  My issue is that a copy of 2 instances
of a news
modules must be displayed on the home page.

I have 2 news instances that is mounted on /press and another on
/articles.  The home page will have a snap shot of both.  In OpenACS4
rather than making 2 tcl or adp file.  I just used the templating
system.  Basically the news modules use the master template that i
created.  My master template is smart enought to apply the look based
on the URL.  It still uses the skin module but slightly modified.

Anyway what is the best way to do a copy to 2 separate news package
instance?  I would like to do this the OpenACS 4.x way rather than
making a tcl file that gets the data from the db.  There are portlets
right?  Is this the best way?  I want to uses existing OpenACS 4.x
services/features as much as possible.  Thanks.

Jun

Collapse
Posted by Gilbert Price on
Here I am again, with Jerry's help I've got chunks starting in my defaultacs.tcl configuration file, now I'm trying to get chunks to display the infor in my index.adp page. I'm using the following for news and bboard:

News:

<%= [reiterate_through_chunk $db news "< a
href="$news_link">$title< /a> ($pretty_release_date) -
$title< br>
"] %>

Bboard

<%= [reiterate_through_chunk $db threads "< a
href="$msg_id">$one_line< /a>< br>$count recent messages
in< br>$category< br>
"]
My errors are:
[16/Sep/2001:17:02:51][2047.59398][-conn20-] Error: missing "
missing "
    while compiling
"ns_puts -nonewline  [reiterate_through_chunk $db news"
    invoked from within chunk: 0 of adp:
/var/lib/aolserver/servers/defaultacs/www/index2.adp
[16/Sep/2001:17:02:51][2047.59398][-conn20-] Error: missing "
missing "
    while compiling
"ns_puts -nonewline  [reiterate_through_chunk acs threads"
    invoked from within chunk: 1 of adp:
/var/lib/aolserver/servers/defaultacs/www/index2.adp

Thanks...

Collapse
Posted by Gilbert Price on
This cutting and pasting is really tedious in Linux: here I go again,
my news and bboard chunks scripts look like this:

News:

<pre><%= [reiterate_through_chunk $db news "< a
href=""$news_link">$title< /a> ($pretty_release_date) - $title<
br>
"] %></pre>

Board:

<pre><%= [reiterate_through_chunk acs threads "< a
href=""$msg_id">$one_line< /a>< br>$count recent messages
in<br>$category< br>
"] %></pre>

My errors are:

<pre>[16/Sep/2001:17:25:54][2047.76805][-conn28-] Error: missing "
missing "
    while compiling
"ns_puts -nonewline  [reiterate_through_chunk $db news"
    invoked from within chunk: 0 of adp:
/var/lib/aolserver/servers/defaultacs/www/index2.adp
[16/Sep/2001:17:25:54][2047.76805][-conn28-] Error: missing "
missing "
    while compiling
"ns_puts -nonewline  [reiterate_through_chunk acs threads"
    invoked from within chunk: 1 of adp:
/var/lib/aolserver/servers/defaultacs/www/index2.adp
10.104.168.5 - - [16/Sep/2001:17:25:54 -0400] "GET /index2.adp
HTTP/1.1" 200 4941 "" "Mozilla/5.0 (X11; U; Linux 2.4.2-2 i686; en-US;
0.7) Gecko/20010316"
10.104.168.5 - - [16/Sep/2001:17:25:54 -0400] "GET /css/gilprice.css
HTTP/1.1" 200 3054 "" "Mozilla/5.0 (X11; U; Linux 2.4.2-2 i686; en-US;
0.7) Gecko/20010316"</pre>

<p>Thanks, now I think I got it all in...

Collapse
Posted by Don Baccus on
It looks like you have something like
"< a href=""foo">
Two quote in a row in other words. You have to escape the quotes with backslash for one thing, and they must balance for another, which is why the parser's complaining about a missing quote (which in this case appears to be due to an extra quote).