106 Posts
krkr
10 years ago
10
Topic

Hi

How can I rendered fields in one line in site view? Template position override file is already made.

This one gives everything in one line:

<?php echo $cck->getText('travel_period_from'); echo "&nbsp;"; echo $cck->getValue('travel_period_from_to'); echo "&nbsp;";echo $cck->getText('travel_period_to'); ?>


This one wraps each line (all labels are set "clear"):

<?php echo $cck->renderField('travel_period_from'); echo "&nbsp;"; echo $cck->renderField('travel_period_from_to'); echo "&nbsp;";echo $cck->renderField('travel_period_to'); ?>

I want to render fields, not just values

Thnx

Get a VIP membership
106 Posts
krkr
10 years ago
0
Level 1

Hi

Didn't solved this one yet. These are date fields. In Admin side it is Y-m-d in Content it should be shown as d.m.Y so therefore I need them with Typo. If I use d.m.Y in Admin view, it gives everything wrong, date changes with year and shows wrong.

Brgds

106 Posts
krkr
10 years ago
0
Level 1

Hi

How to make fields in one row? Does anyone know? With disabled labels.

Brgds

10 years ago
0
Level 1

Hello krkr

to disable certain labels you can type "none" in the label name field.

Can you post the html output of your fields?

106 Posts
krkr
10 years ago
1
Level 1

Hi gebeer

I disable labels with "clear", I think it is the same as "none". Result is the same.

In my override code is:

<?php echo $cck->renderField('travel_period_from') . "&nbsp;" . $cck->getValue('travel_period_from_to') . "&nbsp;" . $cck->renderField('travel_period_to'); ?>

output:

15.10.2013

-

28.02.2013

I would like to have this as:  15.10.2013 28.02.2013

In HTML output:

<div id="cck540_travel_period_from" class="cck_contents cck_content cck_calendar cck_travel_period_from"><div id="cck540_value_travel_period_from" class="cck_value cck_value_calendar">15.10.2013</div></div>&nbsp;-&nbsp;<div id="cck540_travel_period_to" class="cck_contents cck_content cck_calendar cck_travel_period_to"><div id="cck540_value_travel_period_to" class="cck_value cck_value_calendar">28.02.2014</div></div>

Only in one case it is possible get several fields in one row: with getValue, BUT then I have problem because I need different format for Date: m.d.Y and therefore I need to use renderField (in Content view I make it with Typo -> Date with format d.m.Y).

In Admin form I found out that it is impossible to save Date field with format d.m.Y , as it change in DB d with Y (ex. input ->03.10.2014 becomes output ->2031.10.14(or smth like this, but never as it was inserted and saved)). 

In short: Admin form Date field with format 2013-01-01  ->  in Content view Date field with Typo Date format Free d.m.Y


Actually after a long searches in forums (old&new) I found that people have this problem that by renderField it is impossible to put several fields in one row. And there were never been any solution for this. For any type of field ...

So I got fu*ked up once more :(

Brgds

154 Posts
WebOne
10 years ago
0
Level 2

Yes, often using some inline styles will work:

http://stackoverflow.com/questions/224602/how-do-you-make-div-elements-display-inline

310 Posts
ricco
10 years ago
0
Level 1

Hi,


If you render the fields they will render with all the html and css they already have.


You have 2 options:

1. Use other commands as getValue, getText ....

2. Change your css


If you provide a link I could have look and hopefully tell you haw to do it using the option 2.


Regards

Ricco

10 years ago
1
Level 1

You can display the date in a different format in your template override than it is saved in the DB, even when using getValue.


The code I use in my position override goes like this:

First take the value from the date field and make it a datetime object

$artDate = new DateTime($cck->getValue('art_created'));

Then echo it in the desired format

<?php echo $artDate->format('d.m.Y'); ?>

Now you don't have to use renderField anymore and can write html to display all in one line.


Hope this helps.

106 Posts
krkr
10 years ago
0
Level 2

Thanks gebeer for idea. It worked out fantastic. in admin i have Y-m-d and in frontend i have d.m.Y

and it is nicely could be done by php in override.

sadly not by seblod :(

Thank you again

106 Posts
krkr
10 years ago
1
Level 1

Solution was for this:

1 in override before html:

<?php $date_from = new DateTime($cck->getValue('travel_period_from'));
$date_to = new DateTime($cck->getValue('travel_period_to')); 
$valid_from = new DateTime($cck->getValue('offer_valid_from'));
$valid_to = new DateTime($cck->getValue('offer_valid_to')); ?>

2. in html:
<div>
<?php echo $cck->renderField('travel_period'); ?>
<?php echo $date_from->format('d.m.Y'); ?>&nbsp;<?php $cck->getValue('travel_period_from_to'); ?>&nbsp;<?php echo $date_to->format('d.m.Y'); ?><?php echo $cck->renderField('travel_dates_exact_plus'); ?><br />
 <?php echo $cck->renderField('offer_valid'); ?>
 <?php echo $valid_from->format('d.m.Y'); ?>&nbsp;<?php $cck->getValue('travel_period_from_to'); ?>&nbsp;<?php echo $valid_to->format('d.m.Y'); ?>
</div>

brgds

106 Posts
krkr
10 years ago
0
Level 2

UPDATE

There starts problem, when date in DB is 0000-00-00 00:00:00 in that case in content it shows up as today Date. Will try to fix it with php (outside of Seblod).

Brgds

Get a VIP membership