Support » Fixing WordPress » mod_rewrite custom script

  • Hello,

    I always had a website without using WordPress and now I want to start using WordPress but some scripts from the old website also have to work with my WordPress website.

    I tried some things and I got it working (a bit).

    This is the script:

    <?php
    /*
    Template Name: Page: Banden
    */
    $website = "ty";
    ?>
            <script type="text/javascript" src="includes/js/jquery.js"></script>
            <script type="text/javascript" src="includes/js/jqueryUI.min.js"></script>
            <script type="text/javascript" src="includes/js/configuratie.js"></script>
    <?php get_header(); ?>
    
        <?php get_template_part( 'framework/inc/titlebar' ); ?>
    
        <div id="page-wrap" class="container">
    
            <div id="content" class="sixteen columns">
            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
                <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
                    <div class="entry">
    <?php
    
        include_once "vars.php";
        include_once "includes/inc/config.inc.php";
        include_once "class/banden.class.php";
        $banden = new banden($dbo);
        if(isset($zomer)){$zomer;}
        if(isset($winter)){$winter;}
        if(isset($allseason)){$allseason;}
        if(isset($overig)){$overig;}
        $seasons = array("ZO"=>$zomer, "WI"=>$winter, "AS"=>$allseason, "OV"=>$overig);
        isset($seasons['ZO']);
        isset($seasons['WI']);
        isset($seasons['AS']);
        isset($seasons['OV']);
        if(isset($_GET['cat']) && isset($_GET['merk']))
        {
    ?>
                <table border="1" class="bandenmerken">
    <?php
        $tyres = $banden->getTyres($_GET['cat'], $_GET['merk']);
        $typearray = array();
        $counter = 0;
        $start = 0;
        foreach($tyres as $tyre)
        {
            if(!in_array($tyre->uitvoeringvoertuigtype, $typearray))
            {
                if($start == 1)
                {
    ?>
                    </tr>
    <?php
                }
    ?>
    <?php
    if($tyre->uitvoeringvoertuigtype == "BW")
    {
    ?>
        </tr>
        </table>
        <table border="1" class="bandenmerken">
    
    <?php
    }
    ?>
    <?php
    if($tyre->uitvoeringvoertuigtype == "X4")
    {
    ?>
    
        </table>
        <table border="1" class="bandenmerken">
    
    <?php
    }
    ?>
                    <tr>
                        <th colspan="2"><?php
                switch($tyre->uitvoeringvoertuigtype)
                {
                    case "AU":
                        echo "Personenwagens";
                        break;
                    case "BW":
                        if (isset($deliveryvan)){ echo $deliveryvan;}
                        break;
                    case "X4":
                        if (isset($x4)){ echo $x4;}
                        break;
                    case "TR":
                        if (isset($truck)){ echo $truck;}
                        break;
                        echo "";
                        break;
                }
    ?></th>
                    </tr>
                    <tr>
    <?php
                array_push($typearray, $tyre->uitvoeringvoertuigtype);
                $counter = 0;
            }
            if($counter == 2)
            {
    ?>
                    </tr>
                    <tr>
    <?php
                $counter = 0;
            }
    ?>
                        <td>
                            <a href="?merk=<?php echo $_GET['merk']; ?>&cat=<?php echo $_GET['cat']; ?>&band=<?php echo $tyre->uitvoeringid; ?>" title="TYFOON <?php echo $tyre->uitvoeringoms; ?>" class="link-class" onclick="javascript:saveScrollPositions();">
                            <h2><?php echo $tyre->uitvoeringoms; ?></h2>
                                <img src="http://www.website.net/banden/<?php if(isset($tyre->uitvoeringfoto) && $tyre->uitvoeringfoto != ""){ echo str_replace(".jpg", "-k.png", urlencode ($tyre->uitvoeringfoto)); } else { echo "empty-k.png"; } ?>" height="120" width="77" alt="<?php echo $tyre->uitvoeringoms; ?>" class="band"/>
                            </a>
                        </td>
    <?php
            $start = 1;
            $counter++;
        }
    ?>
                    </tr>
                </table>
    </div>
    <div class="bandinfo-img">
    <table border="1" class="banden-titel">
    <tr>
    
    <img src="afbeeldingen/zomerband.jpg" height="145" alt="Tyfoon Zomerband>"/>
    
    </tr>
    </table>
    </div>
            <div class="bandinfo">
    <?php
        if(isset($_GET['band']) && is_numeric($_GET['band']))
        {
            $seltyre = $banden->getTyres($_GET['cat'], $_GET['merk'], $_GET['band']);
            if(isset($seltyre[0])){ $seltyre = $seltyre[0]; }
            else { $seltyre = $tyres[0]; }
        }
        else
        {
            $seltyre = $tyres[0];
        }
    ?>
                <div class="bandinfocontainer">
                <table border="1" class="banden-titel-tekst">
                <tr>
                    <th>
                    Over de: TYFOON <?php echo $seltyre->uitvoeringoms; ?>
                    </th>
                </tr>
                <tr>
                <td>
    <?php
                    $teksten = $banden->getTeksten("01", $seltyre->merkcode."-".$seltyre->uitvoeringisb);
                    if(isset($teksten[0]))
                    {
                        echo $teksten[0]->tekstbes;
                    }
    ?>
                </td>
                </tr>
                </table>
                <table border="1" class="banden-titel-tekst">
                <tr>
                    <th>
                    Maten: TYFOON <?php echo $seltyre->uitvoeringoms; ?>
                    </th>
                </tr>
                </table>
                <table border="1" class="bandinfoheader">
                        <tr>
                            <th class="extra">Band maat</th>
                            <th class="extra">XL</th>
                            <th class="extra">LI</th>
                            <th class="extra">SI</th>
                            <th><img src="afbeeldingen/labels/brandstof.png" width="30" height="30" alt="<?php echo isset($fuel)? $fuel: false; ?>"/></th>
                            <th><img src="afbeeldingen/labels/grip.png" width="30" height="30" alt="<?php echo isset($grip)? $grip: false; ?>"/></th>
                            <th><img src="afbeeldingen/labels/geluid.png" width="30" height="30" alt="<?php echo isset($sound)? $sound: false; ?>"/></th>
                            <th><img src="afbeeldingen/labels/geluid_db.png" width="30" height="30" alt="<?php echo isset($sound2)? $sound2: false; ?>"/></th>
                        </tr>
                    </table>
                    <div id="maten-wrapper">
                <table border="1" class="banden-titel">
                <?php
        $maten = $banden->getBandMaten($_GET['merk'], $seltyre->uitvoeringisb);
        foreach($maten as $maat)
        {
    ?>
                            <tr>
                                <td><?php
        echo $maat->artikelmaat;
        if(!empty($maat->artikelhbv) || $maat->artikelhbv != "")
        {
            echo " / ".$maat->artikelhbv;
        }
        if(!empty($maat->artikeldiameter) || $maat->artikeldiameter != "")
        {
            echo " R".$maat->artikeldiameter;
        }
    ?></td>
                                <td class="si"><?php echo preg_replace("/[^A-Z]/", '', $maat->artikel_xl); ?></td>
                                <td class="li"><?php echo preg_replace("/[^0-9]/", '', $maat->artikeldraagvermogen); ?></td>
                                <td class="si"><?php echo preg_replace("/[^A-Z]/", '', $maat->artikeldraagvermogen); ?></td>
                                <td class="eulabel"><?php echo $maat->artikelbrandstof; ?></td>
                                <td class="eulabel"><?php echo $maat->artikelgrip; ?></td>
                                <td class="eulabel"><?php echo (($maat->artikelgeluid == 0) ? "" : $maat->artikelgeluid); ?></td>
                                <td class="eulabel"><?php echo (($maat->artikelgeluid2 == 0) ? "" : $maat->artikelgeluid2); ?></td>
                            </tr>
    <?php
        }
    ?>
    
                </table>
                </div>
                </div>
            </div>
                        <div class="bandinfoimage">
                    <a href="#" title="TYFOON <?php echo $tyre->uitvoeringoms; ?>" onclick="fx.changeImage('<?php if(isset($seltyre->uitvoeringfoto) && $seltyre->uitvoeringfoto != ""){ echo str_replace(".jpg", "", $seltyre->uitvoeringfoto); } else { echo "empty"; } ?>', this); return false;">
                        <img src="afbeeldingen/vergroot.png" height="21" width="22" alt="zoom" class="zoom"/>
                        <img src="http://www.website.net/preview/<?php  if(isset($seltyre->uitvoeringfoto) && $seltyre->uitvoeringfoto != ""){ echo str_replace(".jpg", ".jpg", urlencode ($seltyre->uitvoeringfoto)); } else { echo "empty.png"; } ?>" height="325" width="237" alt="<?php echo $seltyre->uitvoeringoms; ?>" class="band"/>
                    </a>
                </div>-->
    <?php
        }
        else
        {
    ?>
            <table border="1" class="bandenmerken">
                <tr>
    <?php
            if(!isset($_GET['type']))
            {
                $_GET['type'] = "IMPORT";
            }
            $merken = $banden->getMerkByCat($_GET['type']);
            $counter = 0;
            foreach($merken as $merk)
            {
                $control = $banden->controlTyreCat($merk->merkcode);
                if(isset($control[0]) && !empty($control[0]->uitvoeringid))
                {
                    if($counter == 5)
                    {
                        echo "\t\t\t</tr>
    \t\t\t<tr>\n";
                        $counter = 0;
                    }
                    echo "\t\t\t\t<td>
    \t\t\t\t\t<img src=\"http://www.website.net/logos/".str_replace(".png", "_125.png", $merk->merklogo)."\" width=\"125\" height=\"53\" alt=\"".$merk->merkoms."\" class=\"logo\"/><br/>
    \t\t\t\t\t<div class=\"types\">\n";
                    foreach($seasons as $seasonkey => $season)
                    {
                        $control = $banden->controlTyreCat($merk->merkcode, $seasonkey);
                        if(isset($control[0]) && !empty($control[0]->uitvoeringid))
                        {
    ?>
                            <a href="?merk=<?php echo $merk->merkcode; ?>&cat=<?php echo $seasonkey; ?>">> <?php echo $season; ?></a><br/>
    <?php
                        }
                    }
                    echo "\t\t\t\t\t</div>
    \t\t\t\t</td>\n";
                    $counter++;
                }
            }
    ?>
                </tr>
            </table>
    <?php
        }
    ?>
    
    <?php
    the_content();
    ?>
    
                        <?php wp_link_pages(array('before' => 'Pages: ', 'next_or_number' => 'number')); ?>
    
                    </div>
    
                </article>
    
                <?php if(!$data['check_disablecomments']) { ?>
                    <?php comments_template(); ?>
                <?php } ?>
    
                <?php endwhile; endif; ?>
            </div> <!-- end content -->
    
        </div> <!-- end page-wrap -->
    
    <?php get_footer(); ?>

    I have set my permalinks like this:

    /%category%/%postname%/

    and I have a page that is like this:

    http://www.website.nl/zomerbanden/

    But to make the script work the URL should like this:

    http://www.website.nl/zomerbanden/?merk=TY&cat=ZO&band=1874

    Then you get the tires in that category with de first tire selected.

    I know WordPress is using mod_rewrite for post and pages but is it possible to make my URL (http://www.website.nl/zomerbanden/?merk=TY&cat=ZO&band=1874) look like this:

    http://www.website.nl/zomerbanden/tyfoon/zomer/connexion/

    Thanks

  • The topic ‘mod_rewrite custom script’ is closed to new replies.