Using smarty template (*.tpl) what is {#name#} - smarty

I am not that familiar with *.tpl and i'm working on a code developed by another person that I can not connect to, however I stumbled across a weird syntax that I can't understand and cant find any answers for it online.
What is {#word#}? it's contained in the following code
<td align="left" class="questionClas">{#route#|capitalize}</td>
<td align="left" colspan="2">
<input type="hidden" name="route_id" id="route_id" readonly />
<span id="routeac" class="text_normal" style="font-weight:bold"></span>
</td>
And that is rendered in HTML:
<td align="left" class="questionClas">Route</td>
<td align="left" colspan="2">
<input type="hidden" name="route_id" id="route_id" readonly="">
<span id="routeac" class="text_normal" style="font-weight:bold"></span>
</td>
I figured that it displays the text contained within the hashtags but it isn't and seems to be a variable however I cant find that variable in anywhere else in the file.
Any help would be really appreciated.

Those are variables loaded from config files.

Related

Failure to render B64encoded Thymeleaf

I have searched many hours on here and across the Internet an am unable to render a properly B64 encoded image in an object. I have tried every permutation of diacriticals and nothing. Can someone inform the correct
<tr th:each="re:${reorderList}">
<td th:text="${re.invoiceNum}"></td>
<td th:text="${re.ordered}"></td>
<td th:text="${re.shipped}"></td>
<td th:text="${re.sku}"></td>
<td ><img th:src="${'data:image/jpg;base64,'+ re.upc_s" ></td>
<td th:text="${re.upc01_s}"></td>
<td th:text="${re.brand}"></td>
<td th:text="${re.desc}"></td>
<td th:text="${re.stdCost}"></td>
</tr>
You're missing the ending curly brace in the th:src attribute of your <img /> tag. The expression should be:
th:src="${'data:image/jpg;base64,'+ re.upc_s}"
I would personally represent this as:
<img th:src="|data:image/jpg;base64, ${re.upc_s}|" />

Form submission verification through Ruby script

I have a file which has a form the following HTML code:
<label for="subject">Subject</label>* : <input name="subject" id="subject" type="text">
<br>
<label for="message">Message</label>* : <textarea type="text" name="message" id="message"></textarea>
<br>
<input name="name" id="name" value="" type="hidden">
<input value="Submit Ticket" onclick="submitTicket()" type="button">
After I submit the form, the respective ticket will be in a table which has the following HTML code:
<table class="list" width="100%">
<tbody><tr class="messagelist">
<th>#</th>
<th>ID</th>
<th>Name</a></th>
<th>Subject</a></th>
<th>Owner</a></th>
<th>Priority</a></th>
</tr>
<tr class="list_row">
<td>1.</td>
<td>14</td>
<td class="name">X</td>
<td class="subject">Test1</td>
<td class="owner">AB</td>
<td class="priority">High</td>
</tr>
<tr class="list_row">
<td>2.</td>
<td>22</td>
<td class="name">Y</td>
<td class="subject">Test2</td>
<td class="owner">CD</td>
<td class="priority">Low</td>
</tr>
<tr class="list_row">
<td>3.</td>
<td>31</td>
<td class="name">Z</td>
<td class="subject">Test3</td>
<td class="owner">EF</td>
<td class="priority">Medium</td>
</tr>
<tr class="list_row">
<td>4.</td>
<td>42</td>
<td class="name">A</td>
<td class="subject">Test4</td>
<td class="owner">GH</td>
<td class="priority">High</td>
</tr>
<tr class="list_row">
<td>5.</td>
<td>34</td>
<td class="name">B</td>
<td class="subject">Test5</td>
<td class="owner">IJ</td>
<td class="priority">Low</td>
</tr>
<tr class="list_row">
<td>6.</td>
<td>43</td>
<td class="name">C</td>
<td class="subject">Test6</td>
<td class="owner">KL</td>
<td class="priority">Medium</td>
</tr>
</tbody></table>
I am writing a RUBY code for the above form and ticket. I want to verify the submitted form and ticket with respect to subject Test1. Based on the subject, I want to click the ID link of Test1.
Could anyone please help how to do this?
Here is what I tried:
require 'watir'
browser.tds(:class, 'list_row').each do |tds_row|
if tds_row.text =~ /Test1/
tds_row.a(:href, 'index.html').click
end
end
You can iterate over the table rows, and element of the iterated row will be a table cell. Then, you can examine the text of that cell. If the value of the 4th cell is the one you're looking for (i.e. "Test1"), then click the link in the second cell, and break out of the iteration. Here's a contrived example:
require 'watir'
b = Watir::Browser.new :chrome
b.goto("http://some_url")
b.button(:value => "Submit Ticket").click
b.trs.each do |tr|
if tr[3].text == "Test1"
tr[1].a.click
break
end
end
b.close
It's still clunky and fragile, so it might be better to target the cells based on their class attributes.
Also--in your watir example--it looks like you are trying to locate table cells based on the parent row's class attribute (i.e. browser.tds(:class, 'list_row') instead of browser.tds(:class, 'list_row').
Given that the HTML is well marked-up, iterating through the rows is more complicated than it has to be. It would be easier to find the specific subject cell and then navigate to its parent row.
# Find the cell with the specific subject text
subject = browser.td(class: 'subject', text: 'Test1')
# Get the row
row = subject.parent
# Click the tracking code link
row.link(class: 'trackingcode').click

AJAX: Permission denied to access property in iframe

Hi I created an php website which uses for AJAX post and was live at http://sprook.com.au/ but my client change it's domain to http://www.sprookit.net/ from his service provider Godaddy and now the firebug says:
Permission denied to access property 'stopAjax'
here stopAjax is my method name.
script is there:
<div class="post_area">
<form action="post.php" method="post" id="addVideo" enctype="multipart/form-data" target="post" onsubmit="return startAjax(this);">
<iframe id="post" name="post" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe>
<table width="860" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="435">POST YOUR AD FREE<br />
<em>Paste embed code from YouTube</em></td>
<td width="322"><input type="text" id="videoLink" name="videoLink" class="input_textbox" />
</td>
<td width="95"><input type="submit" name="set_video_link" id="set_video_link" value="" class="submt_post" />
</td>
</tr>
<tr>
<td> </td>
<td><div id="process"> Connecting please wait <img src="images/loading.gif" /><br/>
</div></td>
</tr>
</table>
</form>
</div>
And all content comes from old domain i removed index file and it stoped working, therefore it is cleared that scripts run from old domain.
Most likely you're running into same origin policy issue here as both script and iframe domain must match. You need to verify that all content really comes from new domain and not the old one.

How to display the similar information in every view?

I would like to display the information about user's registration state. It should be displayed on every view, but i consider, that writting this code for about 20 times is a bad idea. By the way, this is the code, it works, i guarantee that:
View/RegistrationInfo:
<table width="95%" border="0" cols="2">
<tr>
<td width="50%" height="124"><h2><strong>Simple Blog </strong></h2></td>
<td width="50%" height="124">
#if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
{
using (Html.BeginForm("LogOff", "Account"))
{
<table width="95%" height="86" border="0">
<tr>
<td width="50%" valign="middle">Hello, #System.Web.HttpContext.Current.User.Identity.Name</td>
<td width="50%" valign="middle" align = "right"><input type="submit" value="Exit" /></td>
</tr>
</table>
}
}
else
{
using (Html.BeginForm("LogIn", "Home"))
{
<table width="95%" height="86" border="0">
<tr>
<td width="45%" valign="bottom">Login:</td>
<td width="45%" valign="bottom">Password:</td>
<td width="10%"></td>
</tr>
<tr>
<td width="45%">
<p>
<input type="text" name="login" />
</p>
</td>
<td width="45%">
<p>
<input type="password" name="password" />
</p>
</td>
<td width="10%" align="left">
<input type="submit" value="Enter" />
</td>
</tr>
<tr>
<td width="45%" valign="top">
#Html.ActionLink("Register", "Register", "Account")
</td>
</tr>
</table>
}
}
</td>
</tr>
</table>
<hr align="left" width="100%" size="2" />
As you can see, this view doesn't require to be strongly typed... and i don't know, should I modify any controllers (because, all information is stored in HTML Context), and how. I tried to call
#Html.RenderAction("RegistrationInfo", "Home");
or
#Html.RenderPartial("RegistrationInfo", "Home");
and every time i receive compile error with message about invalid parametres
While Darin's answer perfectly covers your question, I would point out that registration information seems like it's part of your layout more (master page for the .aspx-inclined) than an actual action.
So what I would do (and indeed, do do) is put it either in the header part of your layout in the top right or under your side menu or something, and let the layout handle all the details of rendering it (with a conditional around it to hide it when you're not logged in, so you don't see it on the login screen).
The following should work:
#Html.Partial("~/Views/Home/RegistrationInfo.cshtml")
Or if you are inside a view of the Home controller simply:
#Html.Partial("RegistrationInfo")
Or if you put this partial in ~/Views/Shared/RegistrationInfo.cshtml you will be able to reference with the shorthand syntax.

How to hide Amazon webstore default toolbar with Prototype?

after playing around this morning, i've found that there's this default chunk of html code in the amazon webstore which will add a toolbar on top of the page. the html looks like below:
<td id="wba_logo_bg">
<table class="logo" border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody><tr><td align="left"></td>
<td class="wba_account" style="padding: 5px;" align="right" valign="top">
<table border="0" cellpadding="0" cellspacing="0">
<form action="#" id="searchForm" method="get" name="searchForm"></form>
<tbody><tr><td class="wba_account_link">
<a xmlns:xhtml="http://www.w3.org/1999/xhtml" class="myAccountNav" href="#" onclick="return false;">home</a></td>
<td class="myAccountDots"></td>
<td class="wba_account_link"><a class="myAccountNav" href="#" onclick="return false;">view cart</a></td>
<td class="myAccountDots"></td><td class="wba_account_link"><a class="myAccountNav" href="#" onclick="return false;">my account</a></td>
<td class="myAccountDots"></td><td class="wba_account_link"><a class="myAccountNav" href="#" onclick="return false;">order status</a></td>
<td><img src="pageEditor_files/1_pixel.gif" hspace="7"></td>
<td><input name="keyword" tabindex="1" type="text"></td>
<td><img alt="Search" class="wba_search_btn" onclick="return false;" onkeyup="if (13==event.keyCode) searchForm.submit();"
src="pageEditor_files/btn_search.gif" style="cursor: pointer;" tabindex="2" title="Search" hspace="3">
</td></tr></tbody>
</table>
</td></tr></tbody>
</table>
</td>
and thus far i was able to use prototype to find those with the class name of wba_account_link and hide them via the codes below:
function hideAmazonToolbar()
{
$("#wba_logo_bg").hide();
}//end function
but what i really want to do is preferably to hide the whole tbody instead, but with my limited prototype skills, i don't really know how to do this. can anybody point me to the right resources on how to get this done?
EDIT
Went higher up and apparently there's a td with an id, and solve it using prototype hide function! man, i love javascript framework :)
You want the up function. I think this should do it.
document.getElementsByClassName('wba_account_link').up('tbody');

Resources