HTML List

kkurtz 01 Dec, 2018
I am trying to list table fields using HTML.
My index event is:
{fn:read_contacts_x_users}
{view:html7}
And the html7 view is:
<table>
<tr>
<th>Username</th>
<th>Name</th>
</tr>
<tr>
<td>{var:read_contacts_x_users.Contacts.username}</td>
<td>{var:read_contacts_x_users.Contacts.name}</td>
</tr>
</table>

Where read_contacts_x_users is the function and Contacts is the model name. I have tried various combinations here and nothing works. I get the header row but nothing else.
What am I doing wrong?
Karen
healyhatman 01 Dec, 2018
Well for a start you'd surely want a loop, to make a row for each entry, right?

And why not just use the TABLE view instead of making a manual one?
kkurtz 02 Dec, 2018
I'll see if I can figure out how to make a loop.

Why not use a TABLE view? - I am try to learn how to do a printer friendly page and I understand you have to format it with an HTML view.

What I really want to do is construct a form (which I know how to do) and then print the form. Can you point me in the right direction on the printing part?
Thanks,
Karen
kkurtz 02 Dec, 2018
Bob,

I have constructed a very simple form in CF6. I should explain that this is not a fill-in form but is intended for the user to print and then mail in. Yes I know this is dark ages, but that is just how things work at the moment.

Right now the form has just has just a custom HTML section:
<div id="print_div">
<p>Preferred Course:_____________________________________</p>
<p>Alternate Choice: _____________________________________</p>
</div>
And a button

Then in the Setup in the Submit section I copied in the jQuery code in the FAQ:
<?php
$jdoc = \JFactory::getDocument();
$script = "
jQuery(document).ready(function(jQ){
function printPage()
{
var html, css, csss_file, printWin;
css = \"\";
css = \"<style type='text/css'>\"+css+\"</style>\";
css_url = '';
if ( css_url !== '' ) {
css_url = \"<link rel='stylesheet' type='text/css' href='\"+css_url+\"' media='print' />\";
}
html = '<html><head>'+css+css_url+'</head>'+jQ(id).html()+'</html>';

printWin = window.open('', '', 'left=100, top=100, width=600, height=400, toolbar=0, scrollbars=0, status=0' );
printWin.document.write(html);
printWin.document.close();
printWin.focus();
printWin.print();
printWin.close();
}
var id;
id = '#print_div';
jQ('#print_button').css('visibility', 'visible');
jQ('#print_button').click(printPage);
});
";
$jdoc->addScriptDeclaration($script);
?>

On Submit I am getting an error message:
HTML List image 1
Any suggestions?
Karen
healyhatman 02 Dec, 2018
If you don't need them to fill anything in why bother with a form at all? Make a pdf and just have them download it
kkurtz 02 Dec, 2018
There will be some variability in the information presented on the form. Some of the form info will come out of a table.
healyhatman 02 Dec, 2018
OK that makes more sense then.

The code you used doesn't go in the "Submit" section. It should go in a Custom HTML block in the Design tab.
kkurtz 05 Dec, 2018
I did what you suggested and it was working until it wasn't. The print button doesn't appear now. Here is what I have in the Custom HTML Design block:

<div id="print_div">
<p>Preferred Course:_____________________________________</p>
<p>Alternate Choice: _____________________________________</p>
</div>

<?php
$jdoc = \JFactory::getDocument();
$script = "
jQuery(document).ready(function(jQ){
function printPage()
{
var html, css, csss_file, printWin;
css = \"\";
css = \"<style type='text/css'>\"+css+\"</style>\";
css_url = '';
if ( css_url !== '' ) {
css_url = \"<link rel='stylesheet' type='text/css' href='\"+css_url+\"' media='print' />\";
}
html = '<html><head>'+css+css_url+'</head>'+jQ(id).html()+'</html>';

printWin = window.open('', '', 'left=100, top=100, width=600, height=400, toolbar=0, scrollbars=0, status=0' );
printWin.document.write(html);
printWin.document.close();
printWin.focus();
printWin.print();
printWin.close();
}
var id;
id = '#print_div';
jQ('#print_button').css('visibility', 'visible');
jQ('#print_button').click(printPage);
});
";
$jdoc->addScriptDeclaration($script);
?>

What now?
healyhatman 05 Dec, 2018
I don't see a button in that code
kkurtz 06 Dec, 2018
OK. My bad. I forgot to copy the button code.

Now that the button is back I have another issue. In Firefox I can enhance the button (change the color, placement, etc.). But Chrome ignores my CSS. Is the Semantic UI overriding the CSS?
healyhatman 07 Dec, 2018
I doubt it. Clear Chrome's cache and hard reload.
kkurtz 07 Dec, 2018
That worked. thanks.

In a table list how can I get the contents of a cell to wrap? Or alternatively how can I put a horizontal scroll bar at the bottom of the list?

Thanks again,
Karen
healyhatman 07 Dec, 2018
have a look at the semantic ui documentation it's in there somewhere in layout I think. Midnight here
kkurtz 08 Dec, 2018
As far as I can tell you just have to specify the column width. Text will wrap if it needs to. Seems to work anyway.
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger