Results 1 to 16 of 16

Thread: [solved] How is it possible with Catalog ?

  1. #1
    User
    Join Date
    04-01-10.
    Posts
    292

    Default [solved] How is it possible with Catalog ?

    Hello,

    I got 2 catalogs : cat_team and cat_functions. Team is for recording all the people from the company's team. Functions is for selecting the function of each person from the team (director, manager…)

    In Functions, there are 3 fields : function_en, function_fr and function_es to record the different translations for each function. In Team, there are three select fields : function_en, function_fr, function_es linked to the corresponding field in Functions.

    For the moment, each one must be selected manually. My wish is when selecting the function in english the other two automatically complete with corresponding datas from cat_functions.

    Do I need to use calculation fields with the right sql request ? Or is it to do in a catalog model ?

    I think I can't use Catalog reference because I need this in catalog list, not in catalog reader.

    Thanks for your answers.

  2. #2
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: How is it possible with Catalog ?

    Can't you link to the entire cat_functions row by id? Then display whichever field you need to display in the frontend. In the backend you probably can only display one field as title?

  3. #3
    User
    Join Date
    04-01-10.
    Posts
    292

    Default Re: How is it possible with Catalog ?

    Quote Originally Posted by Ruud
    Can't you link to the entire cat_functions row by id? Then display whichever field you need to display in the frontend. In the backend you probably can only display one field as title?
    I suppose I can but I don't know how. I don't know well php nor mysql syntax. Habe you got an idea ?

  4. #4
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: How is it possible with Catalog ?

    Can you edit templates? Can you post the team member template?

  5. #5
    User
    Join Date
    04-01-10.
    Posts
    292

    Default Re: How is it possible with Catalog ?

    Yes, I can edit templates but for the moment I juste use the standard mod_cataloglist.html5.

  6. #6
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: How is it possible with Catalog ?

    Well, so can you post the template that you are using? Also, the change you want is relative easy, but you do need to know some php basics or you'll be depending on help forever. Perhaps you should look into that as well. This will greatly enhance the possibilities, even if you understand just a little.

  7. #7
    User
    Join Date
    04-01-10.
    Posts
    292

    Default Re: How is it possible with Catalog ?

    For the moment, I just use the native Cataloglist models :

    mod_cataloglist.html5
    Code:
    <?php if (!$this->searchable): ?>
    
    <?php endif; ?>
    <section class="<?php echo $this->class; ?> block"<?php echo $this->cssID; ?><?php if ($this->style): ?> style="<?php echo $this->style; ?>"<?php endif; ?>>
    <?php if ($this->headline): ?>
    
    <<?php echo $this->hl; ?>><?php echo $this->headline; ?></<?php echo $this->hl; ?>>
    <?php endif; ?>
    <span class="total"><?php echo $this->total; ?></span>
    
    <?php if ($this->editEnable): ?>
    <div class="addUrl">Add New Item</div>
    <?php endif; ?>
    
    <?php echo $this->catalog; ?>
    <?php echo $this->pagination; ?>
    
    </section>
    <?php if (!$this->searchable): ?>
    
    <?php endif; ?>
    catalog_full.html5
    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'] : ''; ?>">
    <?php if($entry['linkEdit']): ?><?php echo $entry['linkEdit']; ?><?php endif; ?>
    <?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"><?php echo $this->noItemsMsg; ?></p>
    <?php endif; ?>
    And yes I know I should learn php a little bit. That's just a matter of time. So thanks for your help. That's another way to learn… ;-)

  8. #8
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: How is it possible with Catalog ?

    I'm sorry, it is a bit more complex then I initially said because this comes out of two tables and you have to work with the way catalog serves it to you. (Which is a good general way to do it). I do not have the time right now to help with this. You would probably have to add an sql query to each record to fetch the correct language.

    Perhaps for you it is easier right now to add two more fields to the team table. Then add two modules that each show the language field of a language, then use each language specific module in the correct place.

    But if you still want what you asked for this generic template I ones made might put you in the right direction. But it does not lookup the correct value. Template was made for an older Catalog version and Contao 2. As you can see I lookup the language and display the lang specific fields. In your case you need to add a db call. This may be "expensive" on resources, so perhaps you should consider having what you need developed, or see if another extension fits you better like ebm or another.

    [code=php:258hw2ou]<span class="syntaxdefault"><?php
    $defaultLang*</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">*</span><span class="syntaxstring">'en'</span><span class="syntaxkeyword">;
    if(</span><span class="syntaxdefault">$GLOBALS</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'objPage'</span><span class="syntaxkeyword">]-></span><span class="syntaxdefault">language</span><span class="syntaxkeyword">)
    {
    </span><span class="syntaxdefault">****$lang*</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">*$GLOBALS</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'objPage'</span><span class="syntaxkeyword">]-></span><span class="syntaxdefault">language</span><span class="syntaxkeyword">;
    }
    else
    {
    </span><span class="syntaxdefault">****$lang*</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">*</span><span class="syntaxstring">'en'</span><span class="syntaxkeyword">;
    }
    </span><span class="syntaxdefault">?>
    <?php*if*</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">count</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$this</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">entries</span><span class="syntaxkeyword">)):</span><span class="syntaxdefault">*?>
    </span>
    <div*class="layout_custom">

    <span class="syntaxdefault"><?php*foreach*</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$this</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">entries*as*$entry</span><span class="syntaxkeyword">):</span><span class="syntaxdefault">*?>
    </span>
    <div*class="item<span class="syntaxdefault"><?php*echo*$entry</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'class'</span><span class="syntaxkeyword">]</span><span class="syntaxdefault">*</span><span class="syntaxkeyword">?</span><span class="syntaxdefault">*</span><span class="syntaxstring">'*'</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$entry</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'class'</span><span class="syntaxkeyword">]</span><span class="syntaxdefault">*</span><span class="syntaxkeyword">:</span><span class="syntaxdefault">*</span><span class="syntaxstring">''</span><span class="syntaxkeyword">;</span><span class="syntaxdefault">*?></span>">
    <h1><span class="syntaxdefault"><?php*echo*$entry</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'data'</span><span class="syntaxkeyword">][</span><span class="syntaxstring">'title_'</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$lang</span><span class="syntaxkeyword">][</span><span class="syntaxstring">'value'</span><span class="syntaxkeyword">];</span><span class="syntaxdefault">*?></span></h1>
    <p*class="description"><span class="syntaxdefault"><?php*echo*$entry</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'data'</span><span class="syntaxkeyword">][</span><span class="syntaxstring">'description_'</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$lang</span><span class="syntaxkeyword">][</span><span class="syntaxstring">'value'</span><span class="syntaxkeyword">];</span><span class="syntaxdefault">*?></span></p>
    </div>
    <span class="syntaxdefault"><?php*endforeach</span><span class="syntaxkeyword">;</span><span class="syntaxdefault">*?>
    </span></div>

    <span class="syntaxdefault"><?php*else</span><span class="syntaxkeyword">:</span><span class="syntaxdefault">*?>
    </span><p*class="info"><span class="syntaxdefault"><?php*echo*$this</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">noItemsMsg</span><span class="syntaxkeyword">;</span><span class="syntaxdefault">*?></span></p>
    <span class="syntaxdefault"><?php*endif</span><span class="syntaxkeyword">;</span><span class="syntaxdefault">*?></span>[/code:258hw2ou]This template assumes you have the fields title_xx and description_xx in each language you have pages for.

  9. #9
    User
    Join Date
    04-01-10.
    Posts
    292

    Default Re: How is it possible with Catalog ?

    Thanks Ruud for this answer.

    Quote Originally Posted by Ruud
    Perhaps for you it is easier right now to add two more fields to the team table. Then add two modules that each show the language field of a language, then use each language specific module in the correct place.
    That's exactly what I've made for the moment. Three select fields to show the three different fields values of the same record from the same linked table. That's why i thought this could be better to have only one field in the BE to choose the right record and then, in the FE, let Contao determine which linked field value to show depending on the page language.First, that's more ergonomic. Two, this could avoid choosing two different record so not the right translation (ie : Manager in English and Président in french)

    Then for know, I got a bigger problem (for me ;-) I'm sorting my catalog list firts by country then by the name. So, I logically get something like :
    France - Paul
    France - Pierre
    Spain - Diego
    Spain -Walter


    I'm looking for I can have :
    <h2>France</h2>
    Paul
    Pierre
    <h2>Spain</h2>
    Diego
    Walter

  10. #10
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: How is it possible with Catalog ?

    You'd have to adjust te code below, but it would do what you ask. It stores the country of each entry. When the country changes the header is printed and new value stored.

    Code:
    <?php $lastCountry = ''; ?>
    <?php if (count($this->entries)): ?>
    
    <?php foreach ($this->entries as $entry): ?>
    
    <?php if($lastCountry!=$entry['data']['country']['value']): ?>
    <h2><?php echo $entry['data']['country']['value']; ?></h2>
    <?php
    $lastCountry = $entry['data']['country']['value'];
    endif;
    ?>
    
    <?php echo $entry['data']['name']['value']; ?>
    
    <?php endforeach; ?>
    
    <?php else: ?>
    <p class="info"><?php echo $this->noItemsMsg; ?></p>
    <?php endif; ?>

  11. #11
    User
    Join Date
    04-01-10.
    Posts
    292

    Default Re: How is it possible with Catalog ?

    Thanks a lot. I'll try it.

  12. #12
    User
    Join Date
    04-01-10.
    Posts
    292

    Default Re: How is it possible with Catalog ?

    Thanks Ruud. That works fine.
    Last thing : country is a select field based on the cat_country cat catalog table. I've created a view_order field (with numbers) to force the order of the country.

    In the script you wrote, how can I force the same order ?

  13. #13
    User
    Join Date
    04-01-10.
    Posts
    292

    Default (Solved) Re: How is it possible with Catalog ?

    Sorry for my last question ! I've found. I just have to use the native sorting function with manual sorting. That's what my client wants and needs.

    Thanks again.

  14. #14
    User
    Join Date
    04-01-10.
    Posts
    292

    Default Re: How is it possible with Catalog ?

    Hello Ruud,

    Thanks for the code below which works fine. I just have a last little thing to solve.
    I show the entries in "two columns" mode. So I give a 50% length to the appropriate div.
    But, if there is an odd number of entries, the first of the next country comes aside the last of the former country… with the <h2>Country name</h2>
    So, how to force "line return" when displaying the country name ?

    Thanks.


    Quote Originally Posted by Ruud
    You'd have to adjust te code below, but it would do what you ask. It stores the country of each entry. When the country changes the header is printed and new value stored.

    Code:
    <?php $lastCountry = ''; ?>
    <?php if (count($this->entries)): ?>
    
    <?php foreach ($this->entries as $entry): ?>
    
    <?php if($lastCountry!=$entry['data']['country']['value']): ?>
    <h2><?php echo $entry['data']['country']['value']; ?></h2>
    <?php
    $lastCountry = $entry['data']['country']['value'];
    endif;
    ?>
    
    <?php echo $entry['data']['name']['value']; ?>
    
    <?php endforeach; ?>
    
    <?php else: ?>
    <p class="info"><?php echo $this->noItemsMsg; ?></p>
    <?php endif; ?>

  15. #15
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: [solved] How is it possible with Catalog ?

    css clear

  16. #16
    User
    Join Date
    04-01-10.
    Posts
    292

    Default Re: [solved] How is it possible with Catalog ?

    Quote Originally Posted by Ruud
    css clear
    That's absolutely that !
    Thanks a lot… again

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
  •