How to make a table in a content item?

More
12 years 1 month ago #43615 by gkhn
Interesting topic :)

I wonder how i can just set up fields like product name/ product price and features
so that user can add these and it creates a nice table

----Product Name
Price -- - - -Features



SOmething like this

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #43618 by igcorreia
The easy way is to use the DEFAULT TEMPLATE, it is a table.

Create a type of content called PRODUCTS with 5/6/7 custom fields and assign them to the DEFAULT TEMPLATE create a menu item linked to the category and that is it.

Advanced solution is to create a custom module template that is a table.

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #43622 by gkhn

igcorreia wrote: The easy way is to use the DEFAULT TEMPLATE, it is a table.

Create a type of content called PRODUCTS with 5/6/7 custom fields and assign them to the DEFAULT TEMPLATE create a menu item linked to the category and that is it.

Advanced solution is to create a custom module template that is a table.


thank you for the reply.

What I am actually trying to do is this

<?php if ((isset($item->positions ) ) ) : ?>
<div class="row">
<div class="col-sm-12">
<div class="table-responsive table-bordered table-hover">
<table class="table">

<?php foreach ($item->positions as $field) : ?>
<thead>
<tr>
<?php echo $field->display; ?>
</tr>


</thead>
<?php endforeach; ?>
<?php endif; ?>

<tbody>
<?php if ((isset($item->positions ) ) ) : ?>
<?php foreach ($item->positions as $field) : ?>
<tr>
<?php echo $field->display; ?>

</tr>
<?php endforeach; ?>
<?php endif; ?>
<?php if ((isset($item->positions ) ) ) : ?>
<?php foreach ($item->positions as $field) : ?>
<tr>

<?php echo $field->display; ?>

</tr>
<?php endforeach; ?>
<?php endif; ?>
<?php if ((isset($item->positions ) ) ) : ?>
<?php foreach ($item->positions as $field) : ?>
<tr>
<td> <?php echo $field->display; ?></td>

</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>

</table>
</div>
</div>
</div>


I can dynamically add text field to this using frontend submission.

The problem is if I want to add an image+text inside the table. If I can load the textarea just like the simple text field then my problem is solved :)

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #43623 by gkhn
I even tried loading a module via field but I cannot add prefix and suffix to modules...(<td> </td>)

I addded fields and using <td> prefix and suffix, I can get them work inside the table...(simple text only)

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #43625 by igcorreia
Why don't you create 2 positions per <td> ?

This way you can have many fields inside the same td?

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #43626 by gkhn
Sorry but my head is hurting at the moment :)

Is this what you mean by creating two positions?
Code:
<?php if ((isset($item->positions['tablerow1'] ) ) ) : ?> <?php if ((isset($item->positions['tablerow1a'] ) ) ) : ?> <?php foreach ($item->positions['tablerow1'] as $field) : ?> <?php foreach ($item->positions['tablerow1a'] as $field) : ?> <tr> <?php echo $field->display; ?> </tr> <?php endforeach; ?> <?php endif; ?> <?php endif; ?>

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #43629 by igcorreia
:) Can you try to put on this forum a DESIGN? I help you get it done. with the design I give you the PERFECT solution.

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #43630 by gkhn

igcorreia wrote: :) Can you try to put on this forum a DESIGN? I help you get it done. with the design I give you the PERFECT solution.

design is this

getbootstrap.com/css/#tables-responsive

Table head
user can add anything text only (text field)
for the rows user can add image and/or text
so for example
productname- image- features - description

or

productname - features - descrtiption

(for the second option he can have add his product name and image in the table)

And this table is displayed in the item view.

I am not displaying them in the category or anything.

Thank you.

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #43632 by igcorreia
I see what you mean, you need a custom field,
that has be required by everyones.

You want this right?

1 - IN the item VIEW
2 - You have 1 field that is called Table
3 - and the user can add the number of rows that he wants

Right?

I have done this in the past for many clients. If you want in the item view this is the only way.

----

This solution that I am going to explain now is as a more complicated solution to implement but it works the same.

1 - Create a category called PRODUCTS
2 - Create a relate item and assign it to the item view
3 - In the item the client can select with a RELATED field the Products that he want to shoe in the item
4 - Create a Module with a custom template that load the Related Field Inverse and SCOPE IT by the CURRENT ITEM and the respective RELATED FIELD
5 - Create a custom template that for the item and the you have to do a FOREACh for every FIELD you want.
6 - Resume: the client create the products in the products category and in the ITEM only selected the related ones, the module with do the job.

:) Did you get this?

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #43633 by gkhn

igcorreia wrote: I see what you mean, you need a custom field,
that has be required by everyones.

You want this right?

1 - IN the item VIEW
2 - You have 1 field that is called Table
3 - and the user can add the number of rows that he wants

Right?

I have done this in the past for many clients. If you want in the item view this is the only way.

----

This solution that I am going to explain now is as a more complicated solution to implement but it works the same.

1 - Create a category called PRODUCTS
2 - Create a relate item and assign it to the item view
3 - In the item the client can select with a RELATED field the Products that he want to shoe in the item
4 - Create a Module with a custom template that load the Related Field Inverse and SCOPE IT by the CURRENT ITEM and the respective RELATED FIELD
5 - Create a custom template that for the item and the you have to do a FOREACh for every FIELD you want.
6 - Resume: the client create the products in the products category and in the ITEM only selected the related ones, the module with do the job.

:) Did you get this?


Pheww I think I got it but there should be an easier solution.

Would the code below work in this situation

user creates a table header(4 columns) using frontend submission text fields (you can add multipl text)

i am ok up to this point. I even tested it and I can add infinite number of columns without even creating a table each time i create an item...

Anyways coming to the point.
Code:
<?php if ((isset($item->positions['tablerowimage'])) || (isset($item->positions['tablerowtext']))) : ?> <?php foreach ($item->positions['tablerowimage'] as $field) : ?> <?php foreach ($item->positions['tablerowtext'] as $field) : ?> <tr> <?php echo $field->display; ?> </tr> <?php endforeach; ?> <?php endforeach; ?> <?php endif; ?>

I will assign image field to the tablearrowimage and text field for the tablerowtext.

user creates a row using text field and or image field.
if he creates a second set of these fields and adds his content (click add for text and add container for the image field) would it be created on the second column same row?

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Save