Results 1 to 16 of 16

Thread: Checkbox Items Visibility in Frontend

  1. #1
    User
    Join Date
    07-13-09.
    Posts
    83

    Default Checkbox Items Visibility in Frontend

    Hi,
    I´ve been looking throught the forum and found only one Subject regarding my problem. Still I´m not sure if this is what I´m looking for.

    viewtopic.php?f=27&t=1129&p=4366&hilit=checkbox#p4 366

    Let me describe my problem:
    I have created a Catalog where you can manage concerts. Some of those concerts are part of a Festival. If so there´s a checkbox "Festivals" that - once clicked - brings up a Select menu with all Festivals managed by another catalog.
    Let´s say there´s 3 Festivals so far. "Astronaut Rock", "Baby Glam" and "Crash Metal".
    Now: When a User clicks the "Festival" checkbox the Select Menu comes and the first Festival "Astronaut Rock" is choosen automatically. Even if the User unclicks the Checkbox - the concert is now associated with this Festival.

    Usually I´m solving this kind of Problems in the Template.
    Something like:

    Code:
    <?php if ($entry['data']['text_field']['value']):?>
    <?php echo $entry['data']['another_field']['value']; ?>
    <?php endif; ?>
    unfortunate it seems like it wouldn´t work with this:
    Code:
    <?php if ($entry['data']['festival_checkbox']['value']):?>
    <?php echo $entry['data']['event_festival']['value']; ?>
    <?php endif; ?>
    I don´t quite understand what Thyon explanes in this other post above. So, if somebody could help me out, that would be just to nice!

  2. #2
    User
    Join Date
    06-19-09.
    Location
    Kosice, Slovakia
    Posts
    61

    Default Re: Checkbox Items Visibility in Frontend

    I would say that checkbox value is converted to yes / no string, which always evaluates to true. Try something like (notice the raw key in the first line):
    Code:
    <?php if ($entry['data']['festival_checkbox']['raw']):?>
    <?php echo $entry['data']['event_festival']['value']; ?>
    <?php endif; ?>
    If this doesn't work, try to var_dump($entry['data']['festival_checkbox']) to see what you can use to distinguish between checked and unchecked checkboxes.
    S.C.A.R.E

  3. #3
    User
    Join Date
    07-13-09.
    Posts
    83

    Default Re: Checkbox Items Visibility in Frontend

    Thank you for your help but that didn´t work. :-(

    what exactly is that "raw" key? is there any other options that i could try?
    where - how can i make the var_dump?

    I suppose, that this should be a very often occuring problem - it surprises me that there is nothing in the forum about it.

  4. #4
    User
    Join Date
    06-19-09.
    Location
    Kosice, Slovakia
    Posts
    61

    Default Re: Checkbox Items Visibility in Frontend

    var_dump (or print_r) is your best friend when developing catalog templates.

    You just enter code like this to your template:
    Code:
    <?php var_dump($this); ?>
    This will output content of $this object, which is a template object, displaying all variables assigned to template. Very usefull.

    However you may also display content of any other variable. Simply putting <?php var_dump($entry); ?> instead of your code will display contents of $entry variable. You will see it is an array or object with data key, which contains another array of all fields etc. etc.

    There was once raw key that (unlike the value key) contained value directly loaded from database. value was already processed, i.e. changed checkbox to yes / no, file to <a href=..."> etc. etc. But I guess it is removed already.

    If you didn't understand anything, just place this line above your original code (the code you posted here before):
    Code:
    <?php var_dump($entry['data']['festival_checkbox']); ?>
    and let me know what is the output on the frontend.
    S.C.A.R.E

  5. #5
    User
    Join Date
    07-13-09.
    Posts
    83

    Default Re: Checkbox Items Visibility in Frontend

    First of all, thank you very much - I really appreciate your help.
    Second here´s the link: I let the var_dump in the template for the next 15 minutes. it´s maybe easier for you to see.
    And here a copy/paste starting from my checkbox-field ["veranstalter_festival_check"]:
    http://grazjazz.at.dd14304.kasserver.com/konzerte.html

    [code]["veranstalter_festival_check"]=> string(0) "" ["event_festival"]=> string(0) "" ["page"]=> string(0) "" } } } ["Environmentrotected"]=> object(Environment)#2 (1) { ["arrCacherotected"]=> array(4) { ["httpAcceptLanguage"]=> array(1) { [0]=> string(2) "de" } ["base"]=> string(41) "http://grazjazz.at.dd14304.kasserver.com/" ["request"]=> string(13) "konzerte.html" ["ip"]=> string(13) "84.112.126.73" } } ["Sessionrotected"]=> object(Session)#6 (1) { ["arrSessionrotected"]=> array(1) { ["referer"]=> array(2) { ["last"]=> string(45) "/venues-club-details/items/orpheum-extra.html" ["current"]=> string(43) "/venues-club-details/items/fat-tuesday.html" } } } ["Databaserotected"]=> NULL ["Encryptionrotected"]=> NULL ["Stringrotected"]=> NULL ["Filesrotected"]=> NULL ["Userrotected"]=> NULL ["Templaterotected"]=> NULL ["DataContainerrotected"]=> NULL ["Automatorrotected"]=> NULL ["arrCacherotected"]=> array(0) { } } Jazzwerkstatt Graz

    and here a visualisation of my problem. Concerts that are part of a festival get that yellow ribbon. now, once you click that Checkbox, the concert automatically get´s the ribbon from "Jazzwerkstatt Graz", since this is the first Festival in the select field. The user unchecks the field but the ribbon stays.
    http://idisk.me.com/ruhry/Public/Pictur ... 145141.jpg

  6. #6
    User
    Join Date
    06-19-09.
    Location
    Kosice, Slovakia
    Posts
    61

    Default Re: Checkbox Items Visibility in Frontend

    You need to include veranstalter_festival_check to be displayed in your frontend catalog module. I can see that currently you only display event_flyer, event_title, event_date, event_festival, event_subtitle, event_venue, event_preis and event_kategorie. Once you include it, your if condition should work ok. (Supposing you use <?php if ($entry['data']['veranstalter_festival_check']['raw']):?>)
    S.C.A.R.E

  7. #7
    User
    Join Date
    07-13-09.
    Posts
    83

    Default Re: Checkbox Items Visibility in Frontend

    sorry. ["veranstalter_festival_check"] is now included.

    Code:
    "veranstalter_festival_check"]=> array(4) { ["label"]=> string(20) "Teil eines Festivals" ["type"]=> string(8) "checkbox" ["raw"]=> string(0) "" ["value"]=> string(0) "" } } } [1]=> array(8) { ["id"]=> string(2) "46"

  8. #8
    User
    Join Date
    07-13-09.
    Posts
    83

    Default Re: Checkbox Items Visibility in Frontend

    It absolutly works! Thanks a lot!

    It didn´t work at first, because I had already messed around too much in my template! Started from the scrath - works fine!
    Thank you very much!

  9. #9
    User
    Join Date
    06-19-09.
    Location
    Kosice, Slovakia
    Posts
    61

    Default Re: Checkbox Items Visibility in Frontend

    Raw is value as stored in database, this varies from field to field. For checkbox it is empty value if it is not checked or 1 if it is checked. Value is derived from raw in a context specific way, for example if raw contains array of files (in case of file field), raw will contain serialized array, while value will contain something like 'File titleSecond file title' - i.e. some processed value. Of course if you want custom processing of files, it would be difficult to get array of files from value, so you just use raw.

    However this doesn't matter for checkbox I assumed that value would contain "no", so that this would evaluate to true and your ribbon would be displayed. This is obviously not the case So I guess this code does not display your ribbon. You need to have some other code there that adds the ribbon. I assume in some condition with event_festival field. Maybe you could post your template code here?
    S.C.A.R.E

  10. #10
    User
    Join Date
    06-19-09.
    Location
    Kosice, Slovakia
    Posts
    61

    Default Re: Checkbox Items Visibility in Frontend

    I should have read to the end of the thread before posting, I guess
    S.C.A.R.E

  11. #11
    User
    Join Date
    07-13-09.
    Posts
    83

    Default Re: Checkbox Items Visibility in Frontend

    Thank you. It was very informativ anyway.
    But unluckily - after solving this Problem - a new one showed up.

    I have a concert-details site with several catalog-frontend-reader-modules but also a catalog-reference-modul.
    This reference modul creates a link to the festival in which the concerts is happening. everything working.
    Buuuuuuuuuuuut, once I edit a Concert and accidently click the checkbox and save: voila, the reference module in the frontend is loaded pointing to a festival - even though the concert is not part of a festival.

    well, this is puzzeling me. how can i get my code working there?

    at the moment the template for the reference-module looks like this:

    Code:
    <?php if (count($this->entries)): ?>
    
    <div class="layout_full">
    
    <?php foreach ($this->entries as $entry): ?>
    
    <div class="item<?php echo $entry['class'] ? ' '.$entry['class'] : ''; ?>">
    
    
    
    
    <div id="link3">
    <?php echo $entry['data']['festival_name']['value']; ?>
    </div>
    
    
    <?php foreach ($entry['data'] as $field=>$data): ?>
    
    <?php if (strlen($data['raw']) && !in_array($field, array('catalog_name','parentJumpTo'))): ?>
    
    
    <div class="field <?php echo $field; ?>">
    	<div class="label"><?php echo $data['label']; ?></div>
    	<div class="value"><?php echo $data['value']; ?></div>
    </div>
    <?php endif; ?>
    <?php endforeach; ?>
    </div>
    <?php endforeach; ?>
    </div>
    
    <?php else: ?>
    <p class="info">Für diesen Termin ist im Backend kein Veranstalter ausgewählt.</p>
    <?php endif; ?>
    I tried this already
    Code:
    <div id="link3">
    <?php if ($entry['data']['veranstalter_festival_check']['raw']):?>
    <?php echo $entry['data']['festival_name']['value']; ?>
    <?php endif; ?>
    </div>
    no success! :-(

    do you think you can solve this one?

  12. #12
    User
    Join Date
    06-19-09.
    Location
    Kosice, Slovakia
    Posts
    61

    Default Re: Checkbox Items Visibility in Frontend

    I assume this code creates the links, right?
    I would recommend putting <?php var_dump($entry['data']); ?> there to see if veranstalter_festival_check is included there. If it is, just change it to something like
    Code:
    <div id="link3">
    <?php if($entry['data']['veranstalter_festival_check']['raw']): ?>
    <?php echo $entry['data']['festival_name']['value']; ?>
    <?php endif; ?>
    </div>
    Edit: OK, so I should read more carefully. Please post here output of <?php var_dump($entry['data']); ?>
    S.C.A.R.E

  13. #13
    User
    Join Date
    07-13-09.
    Posts
    83

    Default Re: Checkbox Items Visibility in Frontend

    as i´ve said. this was my initial idea. but the code didn´t work.
    it also seems that there is no possibility to include [veranstalter_festival_check] in the reference module...

    it´s quite tricky? isn´t it?

  14. #14
    User
    Join Date
    06-19-09.
    Location
    Kosice, Slovakia
    Posts
    61

    Default Re: Checkbox Items Visibility in Frontend

    I can see in the source code of catalog reference module that there should be field called 'Visible Fields'. Can you see something like this (in BE)? What version of Catalog do you use?
    S.C.A.R.E

  15. #15
    User
    Join Date
    07-13-09.
    Posts
    83

    Default Re: Checkbox Items Visibility in Frontend

    Indeed, there is a field called "visible fields" - but the problem is that the fields that can be activated here are fields from the catalog "festivals" not from the catalog "concerts".
    in other words, none of that fields is the [veranstalter_festival_check].

    catalog 0.3.6 stable - Build 23
    catalog_ext 0.8.9 stable - Build 23

  16. #16
    User
    Join Date
    06-19-09.
    Location
    Kosice, Slovakia
    Posts
    61

    Default Re: Checkbox Items Visibility in Frontend

    I would include code to generate the link to catalog reader template. I don't see any other solution.
    S.C.A.R.E

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •