Skip to content

Commit

Permalink
* Added new component 'news' to eg directory
Browse files Browse the repository at this point in the history
	This component enables the shop owner to easily add news items
	to the foundation catalog.

	A couple of sample news items are also provided to illustrate
	some features.

	A simple:

		cp -r news_feature/* catalogs/the_catalog

	followed by a restart of the server, will install this new feature.

	I welcome any comments for improvement.
  • Loading branch information
Ton Verhagen committed Aug 4, 2001
1 parent a400912 commit 4b96777
Show file tree
Hide file tree
Showing 7 changed files with 314 additions and 0 deletions.
1 change: 1 addition & 0 deletions eg/news_feature/dbconfig/default_db/news.dbm
@@ -0,0 +1 @@
Database news news.txt TAB
19 changes: 19 additions & 0 deletions eg/news_feature/dbconfig/mysql/news.mysql
@@ -0,0 +1,19 @@
Database news news.txt __SQLDSN__
ifdef SQLUSER
Database news USER __SQLUSER__
endif
ifdef SQLPASS
Database news PASS __SQLPASS__
endif
Database news DEFAULT_TYPE text
Database news AUTO_NUMBER 00001

Database news COLUMN_DEF "code=char(64) NOT NULL PRIMARY KEY"
Database news COLUMN_DEF "featured=CHAR(32) NOT NULL DEFAULT '', index(featured)"
Database news COLUMN_DEF "start_date=CHAR(24) NOT NULL DEFAULT '', index(start_date)"
Database news COLUMN_DEF "finish_date=CHAR(24) NOT NULL DEFAULT '', index(finish_date)"
Database news COLUMN_DEF "posted_on=CHAR(24) NOT NULL DEFAULT '', index(posted_on)"
Database news COLUMN_DEF "posted_by=CHAR(64) NOT NULL DEFAULT '', index(posted_by)"
Database news COLUMN_DEF "posted_email=CHAR(64)"
Database news COLUMN_DEF "timed_news=CHAR(8)"

23 changes: 23 additions & 0 deletions eg/news_feature/dbconfig/oracle/news.ora
@@ -0,0 +1,23 @@
Database news news.txt __SQLDSN__
Database news UPPERCASE 1
ifdef SQLUSER
Database news USER __SQLUSER__
endif
ifdef SQLPASS
Database news PASS __SQLPASS__
endif
Database news DEFAULT_TYPE VARCHAR2(2000)
Database news COLUMN_DEF "code=VARCHAR2(64) PRIMARY KEY"
Database news COLUMN_DEF "featured=VARCHAR2(32) DEFAULT ''"
Database news POSTCREATE "CREATE INDEX news_featured ON news (featured)"
Database news COLUMN_DEF "start_date=VARCHAR2(24) DEFAULT ''"
Database news POSTCREATE "CREATE INDEX news_start_date ON news (start_date)"
Database news COLUMN_DEF "finish_date=VARCHAR2(24) DEFAULT ''"
Database news POSTCREATE "CREATE INDEX news_finish_date ON news (finish_date)"
Database news COLUMN_DEF "posted_on=VARCHAR2(24) DEFAULT ''"
Database news POSTCREATE "CREATE INDEX news_posted_on ON news (posted_on)"
Database news COLUMN_DEF "posted_by=VARCHAR2(64) DEFAULT ''"
Database news POSTCREATE "CREATE INDEX news_posted_by ON news (posted_by)"
Database news COLUMN_DEF "posted_email=VARCHAR2(64)"
Database news COLUMN_DEF "timed_news=VARCHAR2(8)"

17 changes: 17 additions & 0 deletions eg/news_feature/dbconfig/pgsql/news.pgsql
@@ -0,0 +1,17 @@
Database news news.txt __SQLDSN__
ifdef SQLUSER
Database news USER __SQLUSER__
endif
ifdef SQLPASS
Database news PASS __SQLPASS__
endif
Database news DEFAULT_TYPE text
Database news COLUMN_DEF "code=varchar(64) NOT NULL PRIMARY KEY"
Database news COLUMN_DEF "featured=varchar(32) DEFAULT '' NOT NULL"
Database news COLUMN_DEF "start_date=varchar(24) DEFAULT '' NOT NULL"
Database news COLUMN_DEF "finish_date=varchar(24) DEFAULT '' NOT NULL"
Database news COLUMN_DEF "posted_on=varchar(24) DEFAULT '' NOT NULL"
Database news COLUMN_DEF "posted_by=varchar(64) DEFAULT '' NOT NULL"
Database news COLUMN_DEF "posted_email=varchar(64)"
Database news COLUMN_DEF "timed_news=varchar(8)"

111 changes: 111 additions & 0 deletions eg/news_feature/pages/news.html
@@ -0,0 +1,111 @@
[comment]
ui_template: yes
ui_template_name: leftright
[/comment]

[tmp page_title]__COMPANY__ -- News[/tmp]
[tmp members_only][/tmp]

[control reset=1]

[control-set]
[component]search_box_small[/component]
[matches]10[/matches]
[/control-set]


[control-set]
[component]category_vertical[/component]
[set_selector]left[/set_selector]
[page_class]all[/page_class]
[timed]0[/timed]
[/control-set]


[control-set]
[component]cart_tiny[/component]
[/control-set]


[control-set]
[component]none[/component]
[/control-set]


[control-set]
[component]cross[/component]
[banner]Specials[/banner]
[cross_codes][/cross_codes]
[size]2[/size]
[cols]2[/cols]
[random][/random]
[/control-set]


[control-set]
[component]news[/component]
[cols]1[/cols]
[news_type]general[/news_type]
[banner]News...[/banner]
[matches]3[/matches]
[timed]60[/timed]
[/control-set]

[control reset=1]

@_LEFTRIGHT_TOP_@

<!-- BEGIN CONTENT -->
<div align=left>
<table width="70%" border="0">
<tr>
<td>
<h2>__COMPANY__ News</h2>

[loop prefix=news more=1 search=|
fi=news
st=db
tf=posted_on
to=r
ml=10

[if session arg]
sf=code
op=eq
se=[data session arg]
[else]
ra=yes
[/else]
[/if]

rf=*
|]

[list]<div>
<b>[news-param title]</b><br>
<small>Posted on [convert-date][news-param posted_on][/convert-date] by [if-news-param posted_email]<a href="mailto:[news-param posted_email]">[news-param posted_by]</a>[else][news-param posted_by][/else][/if-news-param]</small><br>
<br>
[if session arg]
[or value mv_search_match_count == 1]
[news-param body]
[else]
[filter 200][news-param body][/filter]<br>
<a href="[area href="news" arg="[news-param code]"]">Read more...</a>
[/else]
[/if]
</div><br><br>
[/list]
[more-list]
[more]
[/more-list]
[/loop]


</td>
</tr>
</table>
</div>
<br><br><br>
<!-- END CONTENT -->

@_LEFTRIGHT_BOTTOM_@
5 changes: 5 additions & 0 deletions eg/news_feature/products/news.txt
@@ -0,0 +1,5 @@
code featured banner_text banner_image blurb_begin blurb_end timed_news start_date finish_date posted_on posted_by posted_email url title body
00001 general Become an IC Pro... ...start with the tutorial! 20010804 20010804 20010301 Ton Verhagen ton@verhagen.net Interchange Tutorial A new tutorial will familiarize you with many of the basic concepts of Interchange catalogs by leading you through the process of building a catalog from the ground up, all by hand. You'll create every directory and file yourself, and understand what each part does. When you're done, you'll have a very basic but working catalog, but more importantly, we hope you'll have learned a lot about Interchange. You can download it here in PDF format or <a href="http://interchange.redhat.com/cgi-bin/ic/dev/index">read it on the developer site</a>.
00002 general E-Commerce Training... ...gets you up to speed fast! 20010804 20010804 20010605 Ton Verhagen New Red Hat E-Commerce Training Curriculum! Now from Red Hat, the leader in open source software training, comes 2 courses designed to provide the ultimate education on Red Hat Interchange, the world's most widely implemented open source e-Commerce platform.<br><br>IC044 Interchange Fundamentals<br>Durham, NC Red Hat Headquarters<br>Jun 25 - 1 day $598<br>Oct 08 - 1 day $598<br><br><br>IC123 Interchange Developer Essentials<br> Durham, NC Red Hat Headquarters<br>Jun 25-29 - 5 days $2,898<br>Oct 08-12 - 5 days $2,898<br><br><br>Enroll today!<br><br><br>Questions? Call toll free 866-2REDHAT, ext. 7555<br>Outside US? Call 919-547-0012, #3<br>Course descriptions below.<br><br><br>IC044 Interchange Fundamentals<br>Interchange Fundamentals is a one-day overview and demonstration ofRed Hat Interchange aimed at content managers and day-to-day users.<br><br>IC123 Interchange Developer Essentials<br>Interchange Developer Essentials is a five-day hands-on intensive labcourse for developers who will learn how to implement, manage andmaintain a complete e-Commerce store using Red Hat Interchange.
00003 general 20010804 20010804 20010718 Jon Jensen jon@redhat.com Interchange 4.7.6 beta released The first beta release leading to Interchange 4.8 is now available. The release announcement summarizes some of the important new features. You can check it out from CVS or download packages. There is a long list of new features in the WHATSNEW file.
00004 general 20010804 20010804 20010726 Jon Jensen jon@redhat.com Interchange 4.7.7 released A new beta release of Interchange, 4.7.7, is now available for testing.<br>For the most part the changes have been bugfixes. Full details are online:<br><br><br>http://interchange.redhat.com/pub/interchange/WHATSNEW<br><br>Download it from:<br><br>http://interchange.redhat.com/pub/interchange/4.7/<br><br>Thanks to everyone who's been testing and contributing.<br><br>Jon
Expand Down
138 changes: 138 additions & 0 deletions eg/news_feature/templates/components/news
@@ -0,0 +1,138 @@
[comment]
ui_component: news
ui_component_type: content, vertical
ui_component_group: news
ui_component_label: News

news_type:
label: Promotion type
options: general=General, company=Company, products=Products
widget: select

matches:
label: Number to show
widget: select
options: 1,2,3*,4,5,6,7,8,9,10

cols:
label: Columns
options: 1,2,3*,4
widget: select

banner:
label: Banner for top box
default: News
widget: text
width: 40

timed:
label: Use timed build
widget: select
help: Makes more efficient for large/busy catalogs
options: 0=No, 5=5 minutes, 10=10 minutes, 20=20 minutes, 60=60 minutes, 1440=Daily
advanced: 1
[/comment]

<!-- BEGIN COMPONENT [control component news] -->
[timed-build if="[control timed 60]" minutes="[control timed 60]"]
<table width="95%" align=center>
<tr class="categorybar">
<td class="categorybar" align="left"><b>[control banner News]</b></td>
</tr>
<tr>
<td>
[query arrayref=main
sql="
SELECT code,timed_news,start_date,finish_date
FROM news
WHERE featured = '[control news_type general]'
ORDER BY posted_on DESC
"][/query]
[perl tables="news"]
my @out;
my $ref;
my $db;
my $count = 0;
delete $Scratch->{news_codes};
my $date = $Tag->time( { body => '%Y%m%d' } );
$ref = $Tmp->{main} or return;
my $matches = $Tag->control("matches",3);
for(@$ref) {
last if $count++ == $matches;
my $line = $_;
push(@out, $line->[0]), next if ! $line->[1];
next if $line->[2] gt $date;
next if $line->[3] lt $date;
push @out, $line->[0];
}
$Scratch->{news_codes} = join(' ', @out);
return;
[/perl]
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
[table-organize embed=1 pretty=1 cols="[control cols 2]"]
[loop
random="[control matches 3]"
list="[scratch news_codes]"
]
<TD>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td align="center" class="contentbar1">
<b>
[if-loop-data news blurb_begin]
[loop-data news blurb_begin]
[else]
[loop-data news title]
[/else]
[/if-loop-data]</b>
</td>
</tr>
<tr>
<td align="left">
<small>[convert-date][loop-data news posted_on][/convert-date]<br><br></small>
</td>
</tr>

[if-loop-data news banner_image]
<tr>
<td align="center">
<img src="[loop-data news banner_image]" height="80">
</td>
</tr>
[/if-loop-data]
<tr>
<td align="left">
<small>[filter 200][loop-data news body][/filter]</small>
</td>
</tr>

[if-loop-data news blurb_end]
<tr>
<td align="right">
<a href="[area href="news" arg="[loop-code]"]">[loop-data news blurb_end]</a>
</td>
</tr>
[else]
<tr>
<td align="right">
<a href="[area href="news" arg="[loop-code]"]">[loc]Read more[/loc]</a>...&nbsp;
</td>
</tr>
[/else]
[/if-loop-data]
<tr>
<td align="center">&nbsp;</td>
</tr>
</table>
</TD>
[/loop]
[/table-organize]
</table>

<p>&nbsp;</p>

</td>
</tr>
</table>
[/timed-build]
<!-- END COMPONENT [control component news] -->

0 comments on commit 4b96777

Please sign in to comment.