Jump to content


- - - - -

getTemplate Issues...


  • Please log in to reply
26 replies to this topic

#1 Mikey B

Mikey B

    Member

  • Members
  • PipPipPip
  • 20 posts
  • Location:United Kingdom
  • Real Name:Mikey
  • IPB Version:v3.2.x

Posted 18 October 2011 - 04:24 AM

Well I'm trying to make my own application (first ever).. I'm following IPS's official developer stuff.. needless to say that it can get a little confusing and lacking in some areas (from what I can see atm!).

My development board is in IN_DEV. Running 3.2.3.

I have the following code in my doExecute method...

// Get Template
$template = $this->registry->output->getTemplate('featuredcontent')->featured_index();
// send template
$this->registry->getClass('output')->addContent( $template );
// send output
$this->registry->getClass('output')->sendOutput();

In the ACP I've created the skin group skin_featuredcontent and in that group there is the featured_index template.. Yet IPB doesn't show the page. It white-pages!

When I add ini_set('display_errors', 1) to the conf_global.php I get the following error:
Fatal error: Call to undefined method skin_featuredcontent_0::featured_index() in <path>/admin/applications_addon/other/featuredcontent/modules_public/featured/featured.php on line 44

What's going on? Any help is appreciated, I've been going back and forth in the IPS docs and I'm just confused and lost now.

Edited by MadMikeyB, 18 October 2011 - 04:25 AM.


#2 Martin

Martin

    But but, it's not only only!

  • Management
  • PipPipPipPipPipPipPipPipPipPip
  • 7,081 posts
  • Location:Hammerfest, Norway
  • Real Name:Martin Aronsen
  • IPB Version:v3.2.x
Contributor

Posted 19 October 2011 - 07:55 AM

When you're IN_DEV you can't do any of the template editing things in the ACP. Instead you have to do them manually to the "cache" files.

First you have to create a master_skin folder using the tools in ACP -> Look & Feel -> Template Tools.
Attached File  IP.Board_ > System > Look & Feel.png   116.01K   0 downloads

1. Use this to create your master skin and master css folders. If it throws an error, you have to create a couple of folders to hold these files. Those are master_skin, master_skin_mobile and master_skin_xml in /cache/ and master_css, master_css_mobile and master_css_xml in /public/style_css/.
2. & 3. Use this tool when you're ready to build your app, or to store the changes you've made to the database. If you want to install a hook or app while in dev, run those before #1. If you don't, you'll lose your custom templates.
4. & 5. This will write the template files (<appName>_root_templates.xml, etc) to your apps /xml/ folder.


When you want to add a new template group, create a new file named skin_<templateGroup>.php in /cache/master_skin/. The skeleton of such file looks like this:
<?php
class skin_global_1 extends output {

}
Note that all master skin files should have the class "skin_global_1" no matter what.

A typical template looks like this:
//===========================================================================
// Name: defaultHeader
//===========================================================================
function defaultHeader() {
$IPBHTML = "";
//--starthtml--//
$IPBHTML .= <<<EOF
<a href='{$this->settings['board_url']}' title='{$this->lang->words['go_home']}' rel="home" accesskey='1'><img src='{parse replacement="logo_img"}' alt='{$this->lang->words['logo']}' /></a>
EOF;
//--endhtml--//
return $IPBHTML;
}
Template params are added as function arguments.


That's all. Once you get used to it you'll find it to be a lot easier than dealing with the editor in ACP.

#3 Mikey B

Mikey B

    Member

  • Members
  • PipPipPip
  • 20 posts
  • Location:United Kingdom
  • Real Name:Mikey
  • IPB Version:v3.2.x

Posted 20 October 2011 - 05:31 AM

I had already set up IN_DEV by running the buildInDev.php shell script (which created the master_skin stuff in /cache/ I believe), but I was adding templates via the ACP. Now I've added them via the files version, but I still get the error, it's as if IP.Board doesnt know that those files are there, is there something I can do on the ACP side to fix that?

#4 Martin

Martin

    But but, it's not only only!

  • Management
  • PipPipPipPipPipPipPipPipPipPip
  • 7,081 posts
  • Location:Hammerfest, Norway
  • Real Name:Martin Aronsen
  • IPB Version:v3.2.x
Contributor

Posted 20 October 2011 - 06:59 AM

How does you skin cache file look like? If I'm not wrong, any PHP errors in those files will be silent.
Also, did you do the whole "special dev skin with edits to masterMap.php" route? Some seems to recommend it, but I find it useless and really annoying when exporting.

#5 Mikey B

Mikey B

    Member

  • Members
  • PipPipPip
  • 20 posts
  • Location:United Kingdom
  • Real Name:Mikey
  • IPB Version:v3.2.x

Posted 20 October 2011 - 07:06 AM

Nope.

I basically set up a new IP.Board install, then ran the buildInDev.php and started following the tutorial linked in the first post.

But I didn't know about having to edit /cache/master_skin at first so I made the template via the ACP and that did nothing (except error).

So now I have this file /cache/skin_cache/master_skin/skin_featuredcontent.php which looks like this:

<?php
class skin_global_1 extends output
{

	function featured_index()
	{
		$IPBHTML = "";
		//--starthtml--//
		$IPBHTML .= <<< EOF
<h2>{$this->lang->words['featured_title']}</h2>
<div class='general_box'>
<p>
test
</p>
</div>
EOF;
		//--endhtml--//
		return $IPBHTML;
	}
}

But the error persists. It seems that making the template in the ACP first was a bad move, and IPB doesn't know that the above file exists (I deleted the template from the IPB ACP and made the file instead)

Edited by MadMikeyB, 20 October 2011 - 07:06 AM.


#6 Martin

Martin

    But but, it's not only only!

  • Management
  • PipPipPipPipPipPipPipPipPipPip
  • 7,081 posts
  • Location:Hammerfest, Norway
  • Real Name:Martin Aronsen
  • IPB Version:v3.2.x
Contributor

Posted 20 October 2011 - 07:15 AM

Make sure it's actually loading from master_skin. Open /admin/sources/classes/skin/skinFunctions.php, and print our $_dir and $name in loadMasterSkinTemplate().

#7 Mikey B

Mikey B

    Member

  • Members
  • PipPipPip
  • 20 posts
  • Location:United Kingdom
  • Real Name:Mikey
  • IPB Version:v3.2.x

Posted 20 October 2011 - 07:20 AM

Hmm.. I don't think that it is loading the master skin?

This is what I get when I did print_r($dir); print_r($name); in loadMasterSkinTemplate()

Posted Image

#8 Mikey B

Mikey B

    Member

  • Members
  • PipPipPip
  • 20 posts
  • Location:United Kingdom
  • Real Name:Mikey
  • IPB Version:v3.2.x

Posted 20 October 2011 - 07:29 AM

Oh, I'm an idiot. It is using the master skin. I hadn't done $_dir, just $dir.

#9 Martin

Martin

    But but, it's not only only!

  • Management
  • PipPipPipPipPipPipPipPipPipPip
  • 7,081 posts
  • Location:Hammerfest, Norway
  • Real Name:Martin Aronsen
  • IPB Version:v3.2.x
Contributor

Posted 20 October 2011 - 07:41 AM

if( $name == 'skin_featuredcontent' )
{
	print_r( $toeval );
}
If you add that, does that show you any goodies?

#10 Mikey B

Mikey B

    Member

  • Members
  • PipPipPip
  • 20 posts
  • Location:United Kingdom
  • Real Name:Mikey
  • IPB Version:v3.2.x

Posted 20 October 2011 - 07:56 AM

View PostMartin, on 20 October 2011 - 07:41 AM, said:

if( $name == 'skin_featuredcontent' )
{
	print_r( $toeval );
}
If you add that, does that show you any goodies?


Nope, no goodies :(

#11 Martin

Martin

    But but, it's not only only!

  • Management
  • PipPipPipPipPipPipPipPipPipPip
  • 7,081 posts
  • Location:Hammerfest, Norway
  • Real Name:Martin Aronsen
  • IPB Version:v3.2.x
Contributor

Posted 20 October 2011 - 08:29 AM

You wont see anything from that unless you're in your app.
Skip the if() if nothings shows.

#12 Mikey B

Mikey B

    Member

  • Members
  • PipPipPip
  • 20 posts
  • Location:United Kingdom
  • Real Name:Mikey
  • IPB Version:v3.2.x

Posted 20 October 2011 - 08:40 AM

I get this now..

class skin_featuredcontent_0 { /** * Construct */ function __construct( ipsRegistry $registry ) { /* Make object */ $this->registry = $registry; $this->DB = $this->registry->DB(); $this->settings =& $this->registry->fetchSettings(); $this->request =& $this->registry->fetchRequest(); $this->lang = $this->registry->getClass('class_localization'); $this->member = $this->registry->member(); $this->memberData =& $this->registry->member()->fetchMemberData(); $this->cache = $this->registry->cache(); $this->caches =& $this->registry->cache()->fetchCaches(); $this->_funcHooks = array(); } }

I don't know what that code means, though :(

(I had put the print_r before the var was defined, making nothing show, I moved it below).

Edited by MadMikeyB, 20 October 2011 - 12:15 PM.


#13 Martin

Martin

    But but, it's not only only!

  • Management
  • PipPipPipPipPipPipPipPipPipPip
  • 7,081 posts
  • Location:Hammerfest, Norway
  • Real Name:Martin Aronsen
  • IPB Version:v3.2.x
Contributor

Posted 20 October 2011 - 10:54 AM

Can't read the code on my phone.
Is your template in it?

#14 Mikey B

Mikey B

    Member

  • Members
  • PipPipPip
  • 20 posts
  • Location:United Kingdom
  • Real Name:Mikey
  • IPB Version:v3.2.x

Posted 20 October 2011 - 12:15 PM

Nope :(

#15 Martin

Martin

    But but, it's not only only!

  • Management
  • PipPipPipPipPipPipPipPipPipPip
  • 7,081 posts
  • Location:Hammerfest, Norway
  • Real Name:Martin Aronsen
  • IPB Version:v3.2.x
Contributor

Posted 20 October 2011 - 12:49 PM

Go over the name for you skin group. Make sure the exact same is used in your code and the file name, and that the file is readable. Could be something silly like that.

#16 Mikey B

Mikey B

    Member

  • Members
  • PipPipPip
  • 20 posts
  • Location:United Kingdom
  • Real Name:Mikey
  • IPB Version:v3.2.x

Posted 20 October 2011 - 02:35 PM

Updated permissions to 777..

My featured.php file in modules_public calls this now:

$template = $this->registry->output->getTemplate('featuredcontent')->featuredcontent();

then the file is skin_featuredcontent.php, and the func inside is now function featuredcontent()

Everything matches up, yet still the same error :(

Fatal error: Call to undefined method skin_featuredcontent_0::featuredcontent() in <path>/admin/applications_addon/other/featuredcontent/modules_public/featured/featured.php on line 44

Tearing out my hair .. lol.

Edited by MadMikeyB, 20 October 2011 - 02:35 PM.


#17 Martin

Martin

    But but, it's not only only!

  • Management
  • PipPipPipPipPipPipPipPipPipPip
  • 7,081 posts
  • Location:Hammerfest, Norway
  • Real Name:Martin Aronsen
  • IPB Version:v3.2.x
Contributor

Posted 20 October 2011 - 03:15 PM

One thing I just thought of. Add some stuff to skin_global.php > globalTemplate. Do those changes show up?

#18 Mikey B

Mikey B

    Member

  • Members
  • PipPipPip
  • 20 posts
  • Location:United Kingdom
  • Real Name:Mikey
  • IPB Version:v3.2.x

Posted 20 October 2011 - 03:43 PM

View PostMartin, on 20 October 2011 - 03:15 PM, said:

One thing I just thought of. Add some stuff to skin_global.php > globalTemplate. Do those changes show up?
Yes :/

#19 Martin

Martin

    But but, it's not only only!

  • Management
  • PipPipPipPipPipPipPipPipPipPip
  • 7,081 posts
  • Location:Hammerfest, Norway
  • Real Name:Martin Aronsen
  • IPB Version:v3.2.x
Contributor

Posted 20 October 2011 - 03:53 PM

And if you add your template to that group, does you app work?

#20 Mikey B

Mikey B

    Member

  • Members
  • PipPipPip
  • 20 posts
  • Location:United Kingdom
  • Real Name:Mikey
  • IPB Version:v3.2.x

Posted 20 October 2011 - 04:00 PM

View PostMartin, on 20 October 2011 - 03:53 PM, said:

And if you add your template to that group, does you app work?
Nope :/

Fatal error: Call to undefined method skin_global_0::featured() in <path>/admin/applications_addon/other/featuredcontent/modules_public/featured/featured.php on line 44

This really is bizarre




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users