Posts variable empty - handlebars.js

I followed the steps described in this post http://support.ghost.org/create-custom-page-template/ to create a custom page.
What I want to do in this page is show an Index of all my blog posts. Without description, just the header.
So, I created a static page that's on http://myadress/test
And create a page-test.hbs in my root folder. In this file I wrote this code to make a test:
{{!< default}}
<ol class="posts">
{{#foreach posts}}
<table>
<thead>
<tr>
<th>test</th>
</tr>
</thead>
<tbody>
<tr>
<td>test</td>
</tr>
</tbody>
</table>
{{/foreach}}
</ol>
<table>
<thead>
<tr>
<th>test</th>
</tr>
</thead>
<tbody>
<tr>
<td>test</td>
</tr>
</tbody>
</table>
The code inside the foreach is no executed. But what's outside is.
Now, I'm new to Ghost, so probably the posts variable has nothing, right? How do I put the list of posts in there?
Thanks in advance (:

You actually need to put some post data/attributes in there. What you have done is just create the post scope .ie
{{title}} {{content}} {{published_at}} etc....
Take a look here for a list of all the attributes: The post context

Related

Vue template colspan not working properly

Hi im having a issue with a simple problem. because for some reason i dont find anything wrong with my codes. Seems like my code is not reading my colspan. seems like this problem as been mark as duplicate. but i dont want to specify the width of the table since i want the table to be responsive and i use bootstrap table
<div>
<table class="table table-condensed">
<thead>
<tr class="text-uppercase text-contrail table-dark-head">
<th colspan="3">Spillage</th>
<th>Total</th>
<th>Remarks</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">Material Cost / Kg</td>
<td>
<input></input>
</td>
<td>
<input></input>
</td>
</tr>
<tr>
<td>Spillage at 0.5%</td>
</tr>
</tbody>
</table>
</div>
i put this code inside my template. please see the image for the result. The Total and Remarks should be on the right side. but it end up with balance width.

HTML anchor inside a table

The tr id element is not working as a destination for links.
I am trying to create the link www.mywebsite.com/page1.asp#row1
Each of these rows has a picture and description that I need to have go to a distinct url.
The code below is the closest that I have gotten, but it is still not working and I do not know why.
I am building this website in Volusion. This HTML is going into a content block within an already built framework.
<table>
<colgroup><col width="30%">
</colgroup>
<tbody>
<tr id = "row1">
<td><div style="text-align: center;"><img src="/img1.JPG" alt="" align="top" border="0px"></div></td>
<td valign="top">1st Image</td>
</tr>
<tr id = "row2">
<td><div style="text-align: center;"><img src="/img2.JPG=" align="top" border="0px"></div></td>
<td valign="top">2nd Image</td>
</tr>
<tr id = "row3">
<td><div style="text-align: center;"><img src="/img3.JPG" alt="" align="top" border="0px"></div></td>
<td valign="top">3rd Image</td>
</tr>
</tbody>
</table>
The path for the image is wrong I guess. Maybe once check the path like there might be another folder you may have forgot to add (like image/img1.jpg). or maybe try ./ instead of /. Also img2 src is wrong. please correct it

Thymeleaf. Building table from array & list

I got this code:
<th:block th:if="${!#lists.isEmpty(partyInfoByUploaderList)}" th:each="pInfo : ${partyInfoByUploaderList}">
<h4 th:text="${pInfo.getCharName()}"></h4>
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th:block th:if="${!#lists.isEmpty(pInfo.getCharColumnTitles())}" th:each="title: ${pInfo.getCharColumnTitles()}">
<td th:text="${title}"></td>
</th:block>
</tr>
</thead>
<tbody>
<tr>
<th:block th:each="val: ${pInfo.getCharColumnValues()}">
<td th:text="${val}"></td>
</th:block>
</tr>
</tbody>
</table>
And I got this result:
http://screenshot.ru/6dfbe559f905a17dff44d360b5d13f28
So this code correctly create table head, and dont parse table body.
BTW, after delpoy this code appear at another place:
<th:block th:each="val: ${pInfo.getCharColumnValues()}">
<td th:text="${val}"></td>
</th:block>
Web source code in browser:
http://screenshot.ru/9d3fab8030c5ca382ab81094e0c1ca86
Question #2:
Why this code produce TemplateProcessingException error?
P.S. Not enough reputation for images, so just links. Soz
According to Thymeleaf Documentation, <th:block></th:block> should wrap <tr></tr> and not the opposite. So you should try this :
<th:block th:each="val: ${pInfo.getCharColumnValues()}">
<tr>
<td th:text="${val}"></td>
</tr>
</th:block>

Looping in Handlebars

I am struggling to see how to use Handlebars with simple string arrays. I have the following object
When looping around the searchParam array I use something like :
{{#each model.searchParam}}
<table class="table table-bordered table-striped">
<thead>
<tr>
<th class="th-narrow">Property</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="label">name</span></td>
<td>{{name}}</td>
</tr>
<tr>
<td><span class="label">type</span></td>
<td>{{type}}</td>
</tr>
</tbody>
</table>
{{/each}}
In the image above, how do I loop around the "searchInclude" array?
{{#each model.searchInclude}}
... wht do I reference here for the contents of the array?
{{/each}}
In case of an array, this will be the value and you can obtain the index with the Handlebar magic keyword #index
{{#each model.searchInclude}}
{{#index}}: {{this}}
{{/each}}

Printing dynamic content with page breaks in asp.net

In my asp.net project I need to print a page with some dynamic content.I followed this article http://www.dotnetcurry.com/ShowArticle.aspx?ID=92 to achieve that and it works fine as long as the content I need to print fits in one page.
But in case of lengthy content, when I click on print button I see a print preview with all the content that needs to be printed and when printed it just prints the content that fits into one page.So I think when I call 'window.print()' it just prints whatever that can fit into a page and does not check if there is anymore content left to print on another page.And I am not sure how do I set the page breaks to get the entire content printed,as it is dynamic content.
Could someone please help me with this?
Thanks
Edit:
Here is some sample HTML rendered.
<table class="Main">
<tr>
<td class=”left bold”>
Some text
</td>
<td>
<span id="Label">Label</span>
</td>
</tr>
<tr>
......
......
</tr>
......
......
......
<tr>
<td>
<table class= “productslist”>
<tbody>
<tr>....</tr>
<tr>....</tr>
<tr class=”productTextAlign”> ......</tr>
<tr class=”additionalOptions”> ..... </tr>
<tr class=”additionalOptions”>.....</tr>
<tr class=”additionalOptions”>.....</tr>
<tr class=”additionalOptions”>.....</tr>
<tr class=”additionalOptions”>.....</tr>
<tr>...</tr>
<tr class=”productTextAlign”></tr>
<tr class=”additionalOptions”>.....</tr>
<tr class=”additionalOptions”>.....</tr>
<tr class=”additionalOptions”>.....</tr>
<tr class=”additionalOptions”>.....</tr>
</tbody>
</table>
</td>
<tr>
</table>
the table with class is 'Main' is a html table and inside that there is another table with class 'productslist' which is actually a repeater. I am trying to apply the 'page break before' to this repeater using
table.productslist
{
page-break-before:auto;
}
which doesnt to work in FF6.0 and it seems to work fine in IE8.
You could use an Active X control for this:
http://www.meadroid.com/scriptx/docs/printdoc.asp
Alternatively you could take a CSS approach:
http://davidwalsh.name/css-page-breaks
https://stackoverflow.com/search?q=css+page+break

Resources