OSCommerce STS template flow-How to get output of a box in html file - oscommerce

I am trying to explore STS template system.
What i need to do is simple.
I just want to show a banner/box in the right column which is added from the OSC admin.
I have done the following steps:
added a banner from admin banner manager.
created a file in the includes/boxes directory under name customBanner.php
added this line in column_right.php include(DIR_WS_BOXES . 'customBanner.php');
And finally added the following code to customBanner.php
<?php
if ($banner = tep_banner_exists('dynamic', '170x158')) {
?>
<br>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><?php echo tep_display_banner('static', $banner); ?></td>
</tr>
</table>
<?php
}
?>
This code is basically used for OSC without STS template.
Now i need to know how STS template giving output in php.html files e.g.<td>$specialbox</td>. I mean how this variable is getting value from the sts.
and how can i show advertisement box in the right column.

You should add to the includes/modules/sts_inc/sts_user_code.php teh following code:
$sts->start_capture();
include(DIR_WS_INCLUDES . 'boxes/customBanner.php');
$sts->stop_capture('specialbox');
It also posible to use your own file to add this code but you should include its name in the admin->modules-> Default -> Files for normal template

You could add as many boxes as you like in the same way:
$sts->start_capture();
include(DIR_WS_INCLUDES . 'boxes/customBanner.php');
$sts->stop_capture('box1');
$sts->start_capture();
include(DIR_WS_INCLUDES . 'boxes/OTHERcustomBanner.php');
$sts->stop_capture('box2');

Related

How can I build a complex e-mail - template plus content saved in a variable - using cfscript instead of cfmail?

This is expanding a bit on a question I asked earlier. Server is CF2016. I'm saving a table of data using savecontent:
savecontent variable = 'mailBody' {
writeOutput('
<table width="99%" style="border-collapse:collapse;width:99%;">
<tr>
<td style="background-color:##09AFFF;color:##FFFFFF;width:30%;padding-left:3px;padding-top:5px;padding-bottom:5px;font-size:12px;font-weight:700;border-bottom:1px solid ##5B5B5B;text-align:left;">Name</td>
<td style="background-color:##09AFFF;color:##FFFFFF;width:15%;padding-top:5px;padding-bottom:5px;font-size:12px;font-weight:700;border-bottom:1px solid ##5B5B5B;text-align:center;">Class</td>
<td style="background-color:##09AFFF;color:##FFFFFF;width:30%;padding-top:5px;padding-bottom:5px;font-size:12px;text-align:left;font-weight:700;border-bottom:1px solid ##5B5B5B;">City,State,ZIP</td>
<td style="background-color:##09AFFF;color:##FFFFFF;width:15%;padding-right:5px;padding-top:5px;padding-bottom:5px;font-size:12px;text-align:left;font-weight:700;border-bottom:1px solid ##5B5B5B;">Amount</td>
</tr>
');
for ( qryPeople in queryPeople ){
writeOutput('
<tr>
<td style="font-size:12px;padding-left:3px;padding-top:3px;padding-bottom:4px;background-color:#thisBgColor#;border-bottom:1px solid ##5B5B5B;">#qryPeople.p_first# #qryPeople.p_last#</td>
<td style="font-size:12px;padding-left:3px;padding-top:3px;padding-bottom:4px;background-color:#thisBgColor#;border-bottom:1px solid ##5B5B5B;text-align:center;">#YEAR(qryPeople.p_graduation)#</td>
<td style="font-size:12px;padding-left:3px;padding-top:3px;padding-bottom:4px;background-color:#thisBgColor#;border-bottom:1px solid ##5B5B5B;">#qryPeople.p_city# #qryPeople.p_state#</td>
<td style="font-size:12px;padding-top:3px;padding-bottom:4px;padding-right:5px;background-color:#thisBgColor#;border-bottom:1px solid ##5B5B5B;">#NumberFormat(qryValue.p_value,'99,999')#</td>
</tr>
');
};
writeOutput('
<tr>
<td colspan="5" style="font-size:11px;padding-left:5px;padding-top:5px;padding-right:5px;padding-bottom:7px;background-color:##09AFFF;color:##FFFFFF;font-style:italic;border-bottom:1px solid ##5B5B5B;">footer text</td>
</tr>
</table>
');
};//end savecontent
Works fine through here - I can output the variable mailBody and I see a styled table suitable for HTML email.
We have stock email templates that we use (.htm) files that are stored centrally. I'm trying to inject this content into one of these templates to be sent.
mailerService = new mail();
mailTemplate = fileRead(application.paths.physicalroot & '\email\project1\templates\people.htm');
mailerService.setTo("me#domain.com");
mailerService.setFrom("support#domain.com");
mailerService.setSubject("People Report");
mailerService.setType("html");
mailerService.send(body=mailTemplate);
In the .htm template file I have
<cfoutput>#mailBody#</cfoutput>
And it's giving me exactly that - #mailBody#. In less complex e-mails I have no problem using something like
<cfoutput>Welcome #qryPeople.p_first# #qryPeople.p_last#</cfoutput>
Or accessing other variables set on the cfscript template that drives the e-mail. But I can't figure out why my savecontent variable isn't working as expected.
SOLUTION - previously trying a savecontent include did not work, but that may have been on ACF 2010. This works on ACF2016.
mailerService = new mail();
savecontent variable="mailTemplate" {
include variables.templatePath & '\email\project1\templates\people.htm';
};
mailerService.setTo("me#domain.com");
People.htm is included and the other savecontent (mailbody) is rendered in the e-mail. Now to figure it out using the newer cfmail() script...
If you only have one "block" to be evaluated, I'd just replace it using a string function:
mailTemplate = fileRead(application.paths.physicalroot & '\email\project1\templates\people.htm');
mailTemplate = replaceNoCase(mailTemplate, "##mailBody##", mailBody, "one");
// continue with mailerService.* methods
Another option is to use include with a saveContent:
This may require that you rename your template from a *.htm to be *.cfm file.
// create mailBody first using your current saveContent
savecontent variable="finalBody" {
include "#application.paths.physicalroot#\email\project1\templates\people.cfm";
}
The variable finalBody should now contain the content from the mailBody variable.
If you can have CF markup in the templates you should be able to get the results you want with this:
<cfsavecontent variable="mailBody">
<cfinclude template="#application.paths.physicalroot#\email\project1\templates\people.htm">
</cfsavecontent>

Angular-xeditable - How to change height of a Textarea as you type in?

Recently I had a request to change the height of a Angular-xeditable TextArea as you type in, I've been trying to do a lot of changes to css but it doesn't work. Any help is highly appreciated.
Here is a solution for this that is to create your own directive on top of Angular-Xeditable. The key thing is when you use that directive and want to inject into Angular-Xeditable, you need to add the prefix "e-". For example, if you directive called "expanding", when you use that directive along with angular-xeditable, the directive name should be "e-expanding"
Have a look at my sample code below. Hope it helps
Link to example code
<h4>Angular-xeditable Textarea (Bootstrap 3)</h4>
<div ng-app="app" ng-controller="Ctrl">
<a href="#" editable-textarea="user.desc" e-expanding >
<pre>{{ user.desc || 'no description' }}</pre>
</a>
</div>

Flask - SQLAlchemy italicizing text imported from db

I have a application that I am pulling data from fields in MySQL database. In some of these fields a some of the text needs to be italicized. For example, in species.html I have a table data "species.Notes" that I am pulling out from the MySQL database. That will render something like this on the page when the application is rendered:
Example:
Tall three tip sagebrush is associated with gray horsebrush (Tetradymia canescens).
The text in parenthesis (i.e. species name) need to be italicized, and the rest needs to remain normal text. I have tried storing the information in the MySQL database with html tags around Tetradymia canescens
<i></i>
<html><i></i></htm>
but that did not work, and I have not been able to find other suggestions online.
For reference (if needed?), here is how the information is being pulled into the html page where it will be displayed.
species.html
<tr>
<th scope="row">Additional Species Information</th>
<td colspan="3">{{ species.Notes }}</td>
</tr>
<tr>
You can use Jinja filters to introduce the italics tag like this:
<td colspan="3">
{{ species.Notes|replace('(', '<i>(')|replace(')', ')</i>')|safe }}
</td>
Ideally you'd preprocess the text with a regex expression and pass it to the template with the tags already there, then you would just need the safe filter alone.

How to create odoo 9.0 QWeb reports step by step

I spent more than 5 hours on searching in google about creating reports in odoo 9.0 but still nothing, I want to make report which looks like tree view, in pdf, using Qweb, Everything what I found was Invoices, but I don't know how to make report in my example.
Let's assume for example that I have folder in odoo addons 'example' with model(example.py, init.py) and view(example_view.xml) folder and init.py, openerp.py, you know simpliest module, and my question is: Tell me what I must to add and where, what I must to write to XML to make a simple report which looks like tree view(this view is in view folder) and nothing more.
I'm example-learning person and I need example to understand something.
Thanks for answer :)
To create a simple report do the following.
Define Report xml file
/addons/example/views/example_report.xml
Load the xml file in your addon by referencing it in
/addons/example/__openerp__.py
in the data section with other xml files.
'data': ['views/example_report.xml'],
Update your addon.
If in the list view for you addon you should be able to select a record (check the checkbox) and then in the more drop down run the report. Or in the form view for the model you should also be able to click on more and run the report from there.
Note: wkhtmltopdf must be properly installed in order for any of this to work. There are instructions at wkhtmltopdf.org (ensure version 0.12.1 at a minimum)
Here is a simple xml report definition. Lets presume you have a fictional model example.model_name with a name (char), and subrecords (one2many), and the subrecords model has a id,name,and date fields.
<openerp>
<data>
<report
id="report_example_model_name"
model="example.model_name"
string="Example Report"
name="example.report_example_report_view"
file="example.report_model_name"
report_type="qweb-pdf"/>
<template id="report_example_report_view">
<t t-call="report.html_container">
<!-- REMEMBER, docs is the selected records either in form view or checked in list view (usually). So the line below says use the following template for each record that has been selected. -->
<t t-foreach="docs" t-as="doc">
<t>
<div class="page">
<h1>Report For <t t-esc="doc.name"/></h1>
<table>
<tr>
<th>ID</th>
<th>Name</th>
<th>Date</th>
</tr>
<t t-foreach="doc.subrecord" t-as="o">
<tr>
<td><t t-esc="o.id"/></td>
<td><t t-esc="o.name"/></td>
<td><t t-esc="o.date"/></td>
</tr>
</t>
</table>
</div>
</t>
</t>
</t>
</template>
</data>
</openerp>

How to make a plone view that inserts other smaller views of content items?

I think this should be simple. I have a folderish TTW dexterity content item (a drop box) that contains folderish TTW dexterity items (proposals). Each proposal contains TTW dexterity reviews that have fields I want to summarize.
I can easily make a view that generates a table as indicated below for any proposal with simple modifications to the folderlisting view:
[review1 link] [criterion_1 value] [criterion-2 value]...
[review2 link] [criterion_1 value] [criterion-2 value]...
.
.
I can also generate a working table view for a drop box by modifying the folderlisting view:
[proposal1 link] [column I would like to insert the above table in for this proposal]
[proposal2 link] [column I would like to insert the above table in for this proposal]
.
.
My problem is I cannot figure out how to insert the first table into the cells in the second column of the second table. I've tried two things:
Within the view template for the dropbox listing, I tried duplicating the repeat macro of the listingmacro, giving it and all its variables new names to have it iterate on each proposal. This easily accesses all of the Dublin core schemata for each review, but I cannot get access to the dexterity fields. Everything I have tried (things that work when generating the first table) yield LocationError and AttributeError warnings. Somehow when I go down one level I lose some of the information necessary for the view template to find everything. Any suggestions?
I've also tried accessing the listing macro for the proposal, with calls like <metal use-macro="item/first_table_template_name/listing"/>. Is this even partially the right approach? It gives no errors, but also does not insert anything into my page.
Thanks.
This solution is loosely based on the examples provided by kuel: https://github.com/plone/Products.CMFPlone/blob/854be6e30d1905a7bb0f20c66fbc1ba1f628eb1b/Products/CMFPlone/skins/plone_content/folder_full_view.pt and https://github.com/plone/Products.CMFPlone/blob/b94584e2b1231c44aa34dc2beb1ed9b0c9b9e5da/Products/CMFPlone/skins/plone_content/folder_full_view_item.pt. --Thank you.
The way I found easiest to create and debug this was:
Create a minimalist template from the plone standard template folder_listing.pt which makes just the table of summarized review data for a single proposal. The template is just for a table, no header info or any other slots. This is a stripped version, but there is nothing above the first statement. A key statement that allowed access to the fields were of the form:
python: item.getObject().restrictedTraverse('criterion_1')
The table template:
<table class="review_summary listing">
<tbody><tr class="column_labels"><th>Review</th><th>Scholarly Merit</th><th>Benefits to Student</th><th>Clarity</th><th>Sum</th></tr>
<metal:listingmacro define-macro="listing">
<tal:foldercontents define="contentFilter contentFilter|request/contentFilter|nothing;
contentFilter python:contentFilter and dict(contentFilter) or {};
I kept all the standard definitions from the original template.
I have just removed them for brevity.
plone_view context/##plone;">
The following tal:sum is where I did some math on my data. If you are
not manipulating the data this would not be needed. Note that I am only
looking at the first character of the choice field.
<tal:sum define="c1_list python:[int(temp.getObject().restrictedTraverse('criterion_1')[0])
for temp in batch if temp.portal_type=='ug_small_grants_review'];
c1_length python: test(len(c1_list)<1,-1,len(c1_list));
c2_list python:[int(temp.getObject().restrictedTraverse('criterion_2')[0])
for temp in batch if temp.portal_type=='ug_small_grants_review'];
c2_length python: test(len(c2_list)<1,-1,len(c2_list));
c1_avg python: round(float(sum(c1_list))/c1_length,2);
c2_avg python: round(float(sum(c2_list))/c2_length,2);
avg_sum python: c1_avg+c2_avg;
">
<tal:listing condition="batch">
<dl metal:define-slot="entries">
<tal:entry tal:repeat="item batch" metal:define-macro="entries">
<tal:block tal:define="item_url item/getURL|item/absolute_url;
item_id item/getId|item/id;
Again, this is the standard define from the folder_listing.pt
but I've left out most of it to save space here.
item_samedate python: (item_end - item_start < 1) if item_type == 'Event' else False;">
<metal:block define-slot="entry"
The following condition is key if you can have things
other than reviews within a proposal. Make sure the
item_type is proper for your review/item.
tal:condition="python: item_type=='ug_small_grants_review'">
<tr class="review_entry"><td class="entry_info">
<dt metal:define-macro="listitem"
tal:attributes="class python:test(item_type == 'Event', 'vevent', '')">
I kept all the standard stuff from folder_listing.pt here.
</dt>
<dd tal:condition="item_description">
</dd>
</td>
The following tal:comp block is used to calculate values
across the rows because we do not know the index of the
item the way the batch is iterated.
<tal:comp define = "crit_1 python: item.getObject().restrictedTraverse('criterion_1')[0];
crit_2 python: item.getObject().restrictedTraverse('criterion_2')[0];
">
<td tal:content="structure crit_1"># here</td>
<td tal:content="structure crit_2"># here</td>
<td tal:content="structure python: int(crit_1)+int(crit_2)"># here</td>
</tal:comp>
</tr>
</metal:block>
</tal:block>
</tal:entry>
</dl>
<tr>
<th>Average</th>
<td tal:content="structure c1_avg"># here</td>
<td tal:content="structure c2_avg"># here</td>
<td tal:content="structure avg_sum"># here</td>
</tr>
</tal:listing>
</tal:sum>
<metal:empty metal:define-slot="no_items_in_listing">
<p class="discreet"
tal:condition="not: folderContents"
i18n:translate="description_no_items_in_folder">
There are currently no items in this folder.
</p>
</metal:empty>
</tal:foldercontents>
</metal:listingmacro>
</tbody></table>
Create another listing template that calls this one to fill the appropriate table cell. Again, I used a modification of the folder_listing.pt. Basically within the repeat block I put the following statement in the second column of the table:
This belongs right after the </dd> tag ending the normal item listing.
</td> <td class="review_summary">
<div tal:replace="structure python:item.getObject().ug_small_grant_review_summary_table()" />
</td>
Note that "ug_small_grant_review_summary_table" is the name I gave to the template shown in more detail above.