Core Coding - Special Text

  • Dycon
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
12 years 3 months ago #25454 by Dycon
Core Coding - Special Text was created by Dycon
Hi all,

A few days ago I had the to add a declaimer to each event that we have... but sometimes that declaimer is not required... so this is what I did...

on each event the need a text that contain the following.


Text text tex [Costo] text text [Title Event] text text text tex [B-Date] text text tex [End Date] text text tex [Title].

So as you can see is has the same data from the detail view or list view which is cost, dates and title, is just the order that is presented and it has to be at the bottom of each event.

So that was simple enough...

this is how is done.

open category/default.php
arround lines 320 - 326
This is your Cue
Code:
<p class="eb_notice"><?php echo $msg ; ?></p> <?php } ?>
After that you can add yout custom code...
Code:
<br /> <hr /> <div> <p>You will need to make a deposit of <?php echo EventBookingHelper::formatCurrency($item->deposit_amount, $this->config, $item->currency_symbol); ?> in order to make a reservation.</p> <p><strong>Note:</strong> in order to get this title: <?php echo $item->title; ?> you will have to be present in the building from <?php echo JHTML::_('date', $item->event_date, $this->config->event_date_format, $param) ; ?> until <?php echo JHTML::_('date', $item->event_end_date, $this->config->event_date_format, $param) ; ?> and finish the training with a minimum rate of 80%, otherwise you will not get this title <?php echo $item->title; ?>, good luck.</p> </div>

that way that text will be in every event,
now, here is the tricky part... not all of our event require this text out of 10 only 2 don't need it...
how do I do that??
in the back end there is no option to show or not the custom text because is hard coded, and you can't use the custom field to get that text with that data in that order... (don't know if it is possible i haven't try it, I just went straight for the hard code...)...
so i have to do some more hard coding...
1 you need to add a new column to the Event table
2 on the administrator/components/com_eventbooking/models/event.php
after line 506 you need to define your row
Code:
$row->ordering = 0 ; $row->published = 0 ; $row->CustomText_eb = 0; // special Text <---

3 in the administrator......./views/event/view.html.php
lines 110 - 113
you add your custom "list"
Code:
$lists['CustomText_eb'] = JHTML::_('select.booleanlist', 'CustomText_eb', ' class="inputbox" ', $item->CustomText_eb);

4 now you need to make sure you can select or make changes to this value in the back end, to do that
in the administrator......./views/event/tmpl/default.php
add a new cell to the table...
lines 172 - 174
Code:
<tr> <td class="key"> <p>Show Special Text?</p> </td> <td> <?php echo $this->lists['CustomText_eb']; ?> </td> </tr>

And you are DONE!!!!!

and now all you have to do is add a little IF Else...

if ($item->CustomText_eb == 0)
echo "";
else
echo " this awesome code"

and that is it!!

it works fine in event list but when I go to see the details of any event, it keep showing the custom text, I wonder why...


I know is not the best hard code, but it does the job...

still I wonder why it shows the custom text in details and it doesn't on the list of event, the code is design to show or not ether way the user view it...

Thanks for taking the time to read my messy code & English...

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

Moderators: Tuan Pham Ngoc