HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


No page output - templates not loading

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#42710 (In Topic #9517)
Avatar

Community saint

After farting around a little bit to get the feel for OCP4 dev, I've been continuously stumped by the

Code

The requested page gave no output.
Thinking I've jumped the gun a wee bit, I created the module and two templates as outlined in the code book, but unfortunately even the example is giving me the same problem. Am I missing something fundamental here?

P.S. How critical are the GUIDs? I looked at guids.dat, but quickly closed it and ran away screaming! ;)

"no violence, no hate, no pain, no enemies
just peace, unity, tolerance and love" - The Beloved

OCP V7 | Advocating monetary reform - FreeOurMoney

Need OCP friendly hosting? Look no further:
Web Hosting, Reseller Hosting, and Dedicated Servers w/cPanel - Elief! - Official hosting partner for ocPortal.
Back to the top
 
Posted
Rating:
#42712
Avatar

Hi,

You can ignore GUIDs, you don't need to use these :).

At a guess, is it that you're calling up a module without a type parameter?

Is this the code from the Code Book you're using…

Code

   function run()
   {
      // Load-up/records dependencies that all screens in the module use
      require_code('downloads');
      require_code('feedback');
      require_lang('downloads');
      require_css('downloads');

      // Get the URL parameter named 'type' into the variable $type
      $type=get_param('type','misc');

      // Decide what to do (delegate)
      if ($type=='tree_view') return $this->tree_view_screen();
      if ($type=='entry') return $this->dloadinfo_screen();
      if ($type=='misc') return $this->category_screen();
      
      // If we get to this point no delegate was found
      return new ocp_tempcode();
   }

In this example you'd need &type=entry or &type=misc or &type=tree_view in the URL. If it wasn't, none of the if's there would trigger, so it would end up returning blank (return new ocp_tempcode();. Returning blank leads to the " The requested page gave no output. " message.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#42738
Avatar

Community saint

Hey Chris! Here is the code I'm using:

Code

<?php
class Module_example
{
       function info()
       {
              // Bare essentials of this function only here because I'm keeping this
              // example as short as possible. We would normally expect this function
              // to be properly defined.
              return array('version'=>1,'hack_version'=>1,'hacked_by'=>1);
       }
       // This is the function called when the module is loaded up to produce
       // output.
       function run()
       {
              // Decide which screen to show
              $type=get_param('type','screen_a');
              switch ($type)
              {
                     case 'screen_a':
                            return $this->screen_a();
                     case 'screen_b':
                            return $this->screen_b();
              }
              return new ocp_tempcode(); // An invalid screen was requested from this module
       }
       function screen_a()
       {
              // We normally would use a lang string but this is a short and simple example.
              $title=get_page_title('Example Title',false); // false='not a lang string'
              // Produce a URL to screen_b of this module ("this module"=same page, same zone)
              $screen_b_url=build_url(array('page'=>'_SELF','type'=>'screen_b'),'_SELF');
              // Return out screen's output, which comes from a template
              return do_template('EXAMPLE_SCREEN_A',array(
                     'TITLE'=>$title,
                     'SCREEN_B_URL'=>$screen_b_url
              ));
       }
       function screen_b()
       {
              // We normally would use a lang string but this is a short and simple example.
              $title=get_page_title('Example Title 2',false); // false='not a lang string'
              // Read in our 'my_checkbox' POST value. Because it's a checkbox, it will only
              // be present if it was actually ticked. So we need to supply a default of 0
              // in case it was not. The checkbox value was defined as "1" in the HTML so
              // we expect it as an integer.
              $_ticked=post_param_integer('my_checkbox',0);
              $ticked=$_ticked==1; // Convert our 0/1 into a proper boolean
              // Return out screen's output, which comes from a template
              return do_template('EXAMPLE_SCREEN_B',array(
                     'TITLE'=>$title,
                     'TICKED'=>$ticked
              ));
       }
}
?>
and I've tried the following URL's:

Code

http://localhost/ocp/site/index.php?page=example&type=screen_a
http://localhost/ocp/site/index.php?page=example&type=screen_b
but both produce no ouput page. example.php is stored in site/pages/minimodules_custom and the two templates in the default theme dir, templates_custom.

"no violence, no hate, no pain, no enemies
just peace, unity, tolerance and love" - The Beloved

OCP V7 | Advocating monetary reform - FreeOurMoney

Need OCP friendly hosting? Look no further:
Web Hosting, Reseller Hosting, and Dedicated Servers w/cPanel - Elief! - Official hosting partner for ocPortal.
Back to the top
 
Posted
Rating:
#42752
Avatar

Ah right, put it it site/pages/modules_custom as this is a full module not a minimodule.

A minimodule is much more rudimentary than this, and simply runs start to end as sequential code. In the case of a full module like this everything is defined here within an class - and if it is run as a minimodule, it would just define that class when it runs but never actually does anything with that class.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: