10 years ago
9
Topic
Hello everyboy,

My Seblod learning process is just an endless set of question....
I will try to describe my last problem

I have a list of items that I want to display and a div under the list allowing to diplay details about the item selected.
I'm trying to modify the template "seb-table" to match with my requirements.

The following code display the list of items (sorry for the indentation) :
<table id="list" <?php echo $class_table; ?>>
[.........]
<tbody>
<?php
$i = 0;
foreach ( $items as $item ) {
?>
<tr <?php echo ${'class_row'.($i % 2)}; ?> data-id="<?php echo $item->getValue('id'); ?>">
<?php
foreach ( $positions as $name=>$position ) {
$fieldnames = $cck->getFields( $name, '', false );
$multiple = ( count( $fieldnames ) > 1 ) ? true : false;
$html = '';
$width = '';
if ( $isFixed ) {
$width = $cck->w( $name );
$width = ( $width ) ? ' width="'.$width.'"' : '';
}
foreach ( $fieldnames as $fieldname ) {
$content = $item->renderField( $fieldname ); // todo: markup from $cck->renderField()
if ( $content != '' && ( $multiple || $item->getMarkup_Class( $fieldname ) ) ) {
$html .= '<div>'.$content.'</div>';
} else {
$html .= $content;
}
}
echo '<td'.$css[$name].$width.'>'.$html.'</td>';
}
?>
</tr>
<?php $i++; } ?>
</tbody>
</table>


It's the original code, I have not modified any line except the data-id attribute.
<tr <?php echo ${'class_row'.($i % 2)}; ?> data-id="<?php echo $item->getValue('id'); ?>">



Of course this function "getValue" does not work...
I would like to add a hidden attribute to read the id of the element when a user click on the table row.
I have done all the necessary stuff with JQUERY for the ajax part.
My only problem is to get the id value of the element displayed in the row.

I have no idea about the functions reachable with the variable $cck.
Declaration :
$cck = CCK_Rendering::getInstance( $this->template )= CCK_Rendering::getInstance( $this->template )
$items = $cck->getItems();




According to you, is it a simple way to get the id?

Important note: In the backend I did not load an id field, I would like to access to the column 'id' of the SQL table

Thanks a lot
Get a VIP membership
10 years ago
0
Level 1
Hello,
I'm doing so many tests without any result for the moment.
<?php
echo $cck->get('id');
echo $cck->get( 'id' )->value;
?>






Impossible to get the id of the item in the list. Someone has an idea?

Thanks a lot.
10 years ago
7
Level 1
Ok I have a result when I try the following code:
echo $cck->id;



Result:
cck1r



It's not what I was looking for.

My list of items shows some data coming from the table mySite_cck_store_form_product_offer
In this table I have a column id (for identification). I just want to collect this id in order to launch an ajax script displaying more information about the item selected by the user.
Do you have any idea?

10 years ago
6
Level 2
try:

<tr <?php echo ${'class_row'.($i % 2)}; ?> data-id="<?php echo $item->id; ?>">

10 years ago
5
Level 3
Thanks very much for your help!
Unfortunately it does not work...
I have still the following result:
<tr class="list-row-pair" data-id="">



This problem drives me crazy.
10 years ago
4
Level 4
Add "article id" to the list view, then:
<tr <?php echo ${'class_row'.($i % 2)}; ?> data-id="<?php echo $item->get('art_id')->value ;?>
10 years ago
3
Level 5
Codigo Aberto, you are my hero!
It's working perfectly, I have just one last question.
When I add "article id" to the list view, the id is visible on my page. Is it possible to hide this field?
In the backend I can't find the option.
Thanks very much for your help

Frontend


Backend

10 years ago
2
Level 6
In label put "clear", variation choose "Empty" and in Typography choose "none".
10 years ago
1
Level 7
Almost! But it seems difficult.
Test 1) - label = "clear", variation = "Empty", Typo= "none"


Test 2) - label = "clear", variation = "Empty", Typo= "transparent"
Even with the test 2) I have a blank td cell. Do you think that I will need to adapt manually the template code source?
10 years ago
0
Level 8
Use Test 1 and put Article id in column C with Article Date
Get a Book for SEBLOD