开发者

How to get the variables from an Array built by parsing a HTML file

Hi I wanted help in a situation where I have a folder called 'slides' and I have multiple text / html files in it like: slide1.html slide2.html slide3.html and so on.....

The structure of these files is like this:

<h2>Title of the Slide</h2>
<p><a href="http://mydomain.com"><img src="icon.png" width="227" height="227" alt="icon" longdesc="http://longdescription" /></a></p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.</p>

3 properties Title, Image and the Description. One in each line.

----------- UPDATE ---------------

I tried as suggested by @MATT but I am getting a blank screen: Here is the script of the entire page for reference. I am working on a Joomla template.

<?php
defined('JPATH_BASE') or die();
gantry_import('core.gantryfeature');

class GantryFeatureTabs extends GantryFeature {
    var $_feature_name = 'tabs';
    function init() {
        global $gantry;

        if ($this->get('enabled')) {
            $gantry->addScript('tabs.js');
            $gantry->addInlineScript($this->_tabs());
        }
    }
    function render($position="") {
        ob_start();
        foreach(glob("/tabs/*.html") as $fileName) {
        $fname = basename( $fileName );
        $curArr = file($fname);
        $slides[$fname ]['title'] = $curArr[0];
        $slides[$fname ]['image-links'] = $curArr[1];
        $slides[$fname ]['description'] = $curArr[2];

        foreach($slides as $key => $value){

            ?>
              <ul id="tabs1" class="tabs">
                <li>
                <a href="<?php echo $demo_tabs_url.$curArr; ?>"><?php echo $value['title'] ?></a>
                </li>
              </ul>
              <div class="clear"></div>
              <ul id="contents1" class="tabs-content">
                  <li>
                  <?php echo $value['image-links'] ?>
                  <?php echo $value['description'] ?>
                  </li>
              </ul>
            <?php
            }}
            ?>
        <?php
        return ob_get_clean();
    }
    function _tabs() {
        global $gantry;
        $js = "
            window.addEvent('load',function() {
                var tabset = new TabSet($$('#tabs1 li a'),$$('#contents1 li'),{
                    cookieName: 'demo-l开发者_Go百科ist'
                });
            });
        ";
        return $js;
    }
}


Try...

<?php

error_reporting(E_ALL);

class GantryFeatureTabs extends GantryFeature 
{
    $_feature_name = 'tabs';
    function init() {
        global $gantry;

        if ($this->get('enabled')) {
            $gantry->addScript('tabs.js');
            $gantry->addInlineScript($this->_tabs());
        }
    }
    function render($position="") {
        ob_start();
        foreach(glob("/tabs/*.html") as $fileName) {
        $fname = basename( $fileName );
        $curArr = file($fname);
        $slides[$fname ]['title'] = $curArr[0];
        $slides[$fname ]['image-links'] = $curArr[1];
        $slides[$fname ]['description'] = $curArr[2];
}

        foreach($slides as $key => $value)
        {        
            ?>
              <ul id="tabs1" class="tabs">
                <li>
                <a href="<?php echo $demo_tabs_url.$curArr; ?>"><?php echo $value['title'] ?></a>
                </li>
              </ul>
              <div class="clear"></div>
              <ul id="contents1" class="tabs-content">
                  <li>
                  <?php echo $value['image-links']; ?>
                  <?php echo $value['description']; ?>
                  </li>
              </ul>
            <?php
        }
        return ob_get_clean();
    }
    function _tabs() {
        global $gantry;
        $js = "
            window.addEvent('load',function() {
                var tabset = new TabSet($$('#tabs1 li a'),$$('#contents1 li'),{
                    cookieName: 'demo-list'
                });
            });
        ";
        return $js;
    }
}

?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜