Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
Hello World Module :D
  • Posted: 23.11.2005, 21:43
     
    EvilArcana
    rank:
    Softmore Softmore
    registered:
     February 2005
    Status:
    offline
    last visit:
    04.02.06
    Posts:
    74
    Ok...I'm looking at the Example module and its FULL of stuff....lots and lots of files, and I'm unsure where to begin...I want to write a module that will basically display a predefined text string on screen based on parameters passed. Kinda like a Hello World...

    No admin functions, no database, nothing fancy...just when you call yoursite.com/index.php?name=Hello you get the text displayed...

    What files from the example can I eliminate to make it the simplest approach?
  • Posted: 23.11.2005, 22:28
     
    Simon
    rank:
    Steering Committee Steering Committee
    registered:
     December 2002
    Status:
    offline
    last visit:
    09.11.08
    Posts:
    13413

    Code

    function Hello_user_main()
    {
       // Get message from URL screen
       $message = pnVarCleanFromInput('message');

       // Create output object
       $pnRender = new pnRender('Hello');

       // Assign message to template
       $pnRender->assign('mymsg', $message);

       // Return / fetch output template
       return $pnRender->fetch(Hello_user_main.htm);
    }


    Then in modules/Hello/pntemplates/Hello_user_main.htm:

    Code

    <!--[$mymsg]-->


    Call the module with

    index.php?module=Hello&message=HelloWorld

    Code from memory and just typed into the forum, hope it works for you (and if any of it is broken, feel free to check against the example module for how it should be done).

    --
    Regards,
    Simon

    itbegins.co.uk - Zikula Consulting

    Please read the Support Guide
  • Posted: 23.11.2005, 23:20
     
    Landseer
    rank:
    Steering Committee Steering Committee
    registered:
     January 2003
    Status:
    offline
    last visit:
    12.11.08
    Posts:
    848
    And your site is open for XSS icon_smile Always use

    Code

    <!--[ $mymsg|pnvarprepfordisplay ]-->


    Frank

    --
    "He is not dangerous, he just wants to play...."
  • Posted: 23.11.2005, 23:36
     
    Simon
    rank:
    Steering Committee Steering Committee
    registered:
     December 2002
    Status:
    offline
    last visit:
    09.11.08
    Posts:
    13413

    Quote

    And your site is open for XSS Smile Always use


    That's true, me trying to over simplify :)

    --
    Regards,
    Simon

    itbegins.co.uk - Zikula Consulting

    Please read the Support Guide
  • Posted: 24.11.2005, 00:01
     
    EvilArcana
    rank:
    Softmore Softmore
    registered:
     February 2005
    Status:
    offline
    last visit:
    04.02.06
    Posts:
    74
    what file does that first block of code go in? pnuser.php?
    where do I define $mymsg?

    Thanx BTW ;) This is VERY helpful.
  • Posted: 24.11.2005, 00:11
     
    EvilArcana
    rank:
    Softmore Softmore
    registered:
     February 2005
    Status:
    offline
    last visit:
    04.02.06
    Posts:
    74
    wait...I think I see where $mymsg comes from...duh...I was thinking it would be in one of the lang folders at first....sorry.
  • Posted: 24.11.2005, 00:25
     
    Simon
    rank:
    Steering Committee Steering Committee
    registered:
     December 2002
    Status:
    offline
    last visit:
    09.11.08
    Posts:
    13413
    Well, you don't have to make the message a URL variable. You could make it a language define if you wanted.

    --
    Regards,
    Simon

    itbegins.co.uk - Zikula Consulting

    Please read the Support Guide
  • Posted: 03.12.2005, 16:52
     
    Jondice
    rank:
    Freshman Freshman
    registered:
     December 2005
    Status:
    offline
    last visit:
    06.12.05
    Posts:
    5
    this was quite helpful :)

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula