About the development of widgets in thinkphp

Source: Internet
Author: User
Class Hotkeywidget extends Widget {
Public function render ($data) {
$node =m (' Hotkey ');//This is the instantiation of a database table
$data = $node->limit (' 0,10 ')->select ();
$data [' list ']= $data;
$content = $this->renderfile (addon_path. '/widgets/hotkey.html ', $data);
return $content;
}



How should I call the data read in the Hotkeywidget class in hotket.html? What should I call if I apply it to a template?


Reply to discussion (solution)

Would you use thinkphp, wouldn't you use a custom?

The same answer ~ ~ ~ Upstairs there is no problem ah.

I also met with the same?? ...

1.widget is generally placed in the Lib directory, such as the leaderboard widget, creating files TopLankWidget.class.php and toplank.html
2. Write the method on the PHP page about the leaderboard, calling {: W (' Toplank ', Array (' ' type ' = ' = ' "'" ') ' on the page}

Call the read-out data:

  • {$L [' goods_id ']}

  • {$L [' category ']}

  • {$L [' sort ']}

  • {$L [' store_id ']}

  • {$L [' Goods_name ']}

  • {$L [' Price ']}

  • {$L [' desc ']}

  • {$L [' img ']}



  • Template calls
    {: W (' Hotkey ')}
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.