1
<?php
    $model = Mage::getModel('custom_homebanner/request')->getCollection()
?>
<div class="owl-carousel"  id="owl-demo-intro" >
    <div class="item">
        <h2 class="all_caps color_white"><?php echo $banner->custom_homebanner_text ?></h2>
        <!-- <figure id="mouse-pointer"></figure> -->
    </div>
    <div class="item">
        <h1 class="color_white all_caps"><?php echo $banner->custom_homebanner_text1 ?></h1>
        <!-- <figure id="mouse-pointer"></figure> -->
    </div>
    <div class="item">
        <h2 class="color_white all_caps"><?php echo $banner->custom_homebanner_text2 ?></h2>
        <!-- <figure id="mouse-pointer"></figure> -->
    </div>
</div>

3 Answers 3

1

Use below code

<?php echo $banner->getCustomHomebannerText(); ?>

Instead of

<?php echo $banner->custom_homebanner_text ?>

If still not works then print your collection and check if the values are correctly showing or not.

4
  • This code is not working.
    – YKB
    Commented May 2, 2018 at 12:29
  • Can you check the model name? Is it correct or recheck the model? Commented May 2, 2018 at 12:55
  • Model name is: custom_homebanner
    – YKB
    Commented May 2, 2018 at 13:03
  • Try this code Mage::getModel('custom/homebanner')->getCollection(); Commented May 2, 2018 at 15:32
1

You are accessing data wrong way. Please follow below way:

  $model = Mage::getModel('custom_homebanner/request')->getCollection();
  foreach($model as $data){
   echo $data->getCustomHomebannerText();
  }
7
  • Try to understand my question and the code which I wrote.
    – YKB
    Commented May 2, 2018 at 12:31
  • have you getting collection ? Commented May 2, 2018 at 12:34
  • Not yet, but I tried the above code also.
    – YKB
    Commented May 2, 2018 at 12:38
  • <?php $model = Mage::getModel('custom_homebanner/request')->getCollection(); foreach($model as $data){ echo $data->getCustomHomebannerText(); }
    – YKB
    Commented May 2, 2018 at 12:39
  • <div class="owl-carousel" id="owl-demo-intro" > <div class="item"> <h2 class="all_caps color_white"><?php echo $banner->custom_homebanner_text ?></h2> </div> <div class="item"> <h1 class="color_white all_caps"><?php echo $banner->custom_homebanner_text1 ?></h1> </div> <div class="item"> <h2 class="color_white all_caps"><?php echo $banner->custom_homebanner_text2 ?></h2> </div> </div>
    – YKB
    Commented May 2, 2018 at 12:39
1

If you are using collection and want to loop and print the data then use for loop to iterate over it.

<?php $model = Mage::getModel('custom_homebanner/request')->getCollection(); ?>
<div>
    <?php foreach($model as $banner): ?>
    <div>
       <h2 class="all_caps color_white"><?php echo $banner->getCustomHomebannerText() ?></h2>
        <!-- <figure id="mouse-pointer"></figure> -->
    </div>
    <div class="item">
        <h1 class="color_white all_caps"><?php echo $banner->getCustomHomebannerText1() ?></h1>
        <!-- <figure id="mouse-pointer"></figure> -->
    </div>
    <div class="item">
        <h2 class="color_white all_caps"><?php echo $banner->getCustomHomebannerText2() ?></h2>
        <!-- <figure id="mouse-pointer"></figure> -->
    </div>
    <?php endforeach; ?>
</div>

If you want the first Item from your collection you should use getFirstItem() method

<?php $model = Mage::getModel('custom_homebanner/request')->getCollection()->getFirstItem(); ?>
<div>
    <div>
       <h2 class="all_caps color_white"><?php echo $model->getCustomHomebannerText() ?></h2>
        <!-- <figure id="mouse-pointer"></figure> -->
    </div>
</div>

If you have Id of the Item you want you can use load() method

<?php $model = Mage::getModel('custom_homebanner/request')->load(1); ?>
<div>
    <div>
       <h2 class="all_caps color_white"><?php echo $model->getCustomHomebannerText() ?></h2>
        <!-- <figure id="mouse-pointer"></figure> -->
    </div>
</div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.