ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Easier way?

July 17, 2008 6:38am

Subscribe [1]
  • #1 / Jul 17, 2008 6:38am

    Rutger

    25 posts

    Moderator’s note: Moved to Howto.

    Hi all,

    This took me some time, but this might be due to the fact that i’m not thinking in the right direction. But i’d thought i’d ask just to make sure.

    I’ve build an ajax form that does some json calls using an id based on options chosen in the previous dropdown box.
    Now, for example, i have to retreive all the series from a specific manufacturer.

    I have a weblog manufacturers and a weblog series. The series weblog has an manufacturere relationship field called “manufacturer_serie”.

    Below is the code of the series template that retreives all the series for a certain manufacturer.

    <?php
    function curPageURL() {
     $pageURL = 'http';
     if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
     $pageURL .= "://";
     if ($_SERVER["SERVER_PORT"] != "80") {
      $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
     } else {
      $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
     }
     return $pageURL;
    }
    
    $queryString = $_SERVER['QUERY_STRING'];
    //echo "1: ".$queryString;
    
    parse_str($queryString);
    //echo $id;
    ?>
    
    [{optionValue:'keuze', optionDisplay: '---Choose a serie---'}, 
    {exp:weblog:entries weblog="series"}
    
      {related_entries id="manufacturer_serie"}
        {if entry_id == "<?php echo $id; ?>"}
      {/related_entries}
    
            {optionValue:'{entry_id}', optionDisplay: '{serie_name}'},
    
      {related_entries id="manufacturer_serie"}
        {/if}
      {/related_entries}
    
    {/exp:weblog:entries}
    ]

    Now the question is, this works, but am i doing this ok?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases