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.


Problem understanding templates

Login / Search

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

Well-settled

Hi,
Since i want to change the Staff function of the OCP to handly my needs more appropiate i have written a small staff.php substitute that woks fine.. yet when i change the template, that is parsed from index_fancier.. to my own i get a dozen errors like:

A parameter, PRE, is referenced in the template, STAFF_ALPHA_LIST, but not passed
A parameter, URL, is referenced in the template, STAFF_ALPHA_LIST, but not passed
.....

the strange thing about this is that i simply Copy and Pasted the contents from the original temnplate into my new one without touching anything else...
Is there something i missed? The php works perfectly with the original template, but not this one...


Template:

Code

{TITLE}<br /><br />{+START,IF_NON_EMPTY,{PRE}}<br />&lt;div class=&quot;index_page_fancier_page_pre&quot;&gt;<br />{PRE}<br />&lt;/div&gt;<br />{+END}<br /><br />{+START,IF_NON_EMPTY,{CONTENT}}<br />&lt;div class=&quot;index_page_fancier_page_entries&quot;&gt;<br />{+START,IF_PASSED,ARRAY}<br />{+START,LOOP,CONTENT}<br />{+START,IF_NON_EMPTY,{_loop_var}}<br />&lt;h2&gt;{_loop_key}&lt;/h2&gt;<br /><br />&lt;div class=&quot;not_too_tall&quot;&gt;<br />{_loop_var}<br />&lt;/div&gt;<br />{+END}<br />{+END}<br />{+START,IF_PASSED,EMPTY}<br />&lt;p class=&quot;nothing_here&quot;&gt;<br />{!NONE}<br />&lt;/p&gt;<br />{+END}<br />{+END}<br />{+START,IF_NON_PASSED,ARRAY}<br />{CONTENT}<br />{+END}<br />&lt;/div&gt;<br />{+END}<br />{+START,IF_EMPTY,{CONTENT}}<br />&lt;p class=&quot;nothing_here&quot;&gt;<br />{!NO_ENTRIES}<br />&lt;/p&gt;<br />{+END}<br /><br />{+START,IF_NON_EMPTY,{POST}}<br />&lt;div class=&quot;index_page_fancier_page_post&quot;&gt;<br />{POST}<br />&lt;/div&gt;<br />{+END}<br /><br />{+START,IF_PASSED,ADD_URL}<br /><br />{+START,INCLUDE,STAFF_ACTIONS}<br />1_URL={ADD_URL*}<br />1_TITLE={!ADD}<br />1_REL=add<br />1_NOREDIRECT=1<br />{+END}<br />{+END}<br />


Page: http://www.alphaclan.org//site/index.php?page=staff2


*edit* I just see that none of the parameters like URL TITLE and so on appear in the dropdown boxes in the template editor - how can i tell the OCP to use those?

btw, what if people use other themes? Will their templates, if missing, fall back to those in the default theme?
Back to the top
 
Posted
Rating:
#64120
Avatar

I'd have to see the PHP code involved, but that error happens if the PRE (or URL) parameter is either not in the do_template call or is passed in as a NULL value.

Yes, ocPortal defaults to the default theme templates if a theme does not have that template. We think of it the other way around though – themes may choose what they wish to override from the default theme.


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:
#64121
Avatar

Well-settled

The PHP File:
<?php


require_once( "lib/steam-condenser.php");


class Module_staff2
{

/**
* Standard modular info function.
*
* @return ?array Map of module info (NULL: module is disabled).
*/
function info()
{
$info=array();
$info['author']='Nachtwind';
$info['organisation']='';
$info['hacked_by']=NULL;
$info['hack_version']=NULL;
$info['version']=2;
$info['locked']=true;
return $info;
}

/**
* Standard modular entry-point finder function.
*
* @return ?array A map of entry points (type-code=>language-code) (NULL: disabled).
*/
function get_entry_points()
{
return array('misc'=>'ALPHASTAFF');
}

/**
* Standard modular uninstall function.
*/
function uninstall()
{
delete_menu_item_simple('_SEARCH:staff2:type=misc');
}

/**
* Standard modular install function.
*
* @param ?integer What version we're upgrading from (NULL: new install)
* @param ?integer What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
*/
function install($upgrade_from=NULL,$upgrade_from_hack=NULL)
{
require_lang('staff');
add_menu_item_simple('main_website',NULL,'Roster','_SEARCH:s
taff2:type=misc');
}

/**
* Standard modular run function.
*
* @return tempcode The result of execution.
*/
function run()
{
require_lang('staff');

$type=get_param('type','misc');

if ($type=='view') return $this->do_staff_member();
if ($type=='misc') return $this->do_all_staff();

return new ocp_tempcode();
}

/**
* The UI to view a staff list.
*
* @return tempcode The UI
*/
function do_all_staff()
{
$title=get_page_title('Alphaclan Roster');

$admin_groups=array_merge($GLOBALS['FORUM_DRIVER']->get_supe
r_admin_groups(),$GLOBALS['FORUM_DRIVER']->get_moderator_grou
ps());
$rows=$GLOBALS['FORUM_DRIVER']->member_group_query($admin_gr
oups);

$pre="These are the currently active members:";

foreach ($rows as $i=>$row_staff)
{
$name=$GLOBALS['FORUM_DRIVER']->pname_name($row_staff);
$rows[$i]['name']=$name;
}

global $M_SORT_KEY;
$M_SORT_KEY='name';
usort($rows,'multi_sort');

$content=new ocp_tempcode();
foreach ($rows as $row_staff)
{

if($row_staff['name'] == "Bishop" )
{
continue;
}


$id=$GLOBALS['FORUM_DRIVER']->pname_id($row_staff);
if (!$GLOBALS['FORUM_DRIVER']->is_staff($id)) continue;
$name=$row_staff['name'];
$url=build_url(array('page'=>'_SELF','id'=>$name,'type'=>'vi
ew'),'_SELF');
$role=get_ocp_cpf('role',$id);
if (is_null($role))
{
$description=''; // Null should not happen, but sometimes things corrupt
} else
{
require_code('comcode_text');


$games = explode("|",get_ocp_cpf('Games',$id));


$description = apply_emoticons($role)."<p>";


//sort($games);


$game="";
//Team Fortress 2,Left for Dead,Left for Dead 2,Alien Swarm,Borderlands
//Liste aller Spiele abklappern und die ausgrauen, die man nicht spielt. Automatisieren? Sowas sieht nicht schön aus…
if (in_array("Team Fortress 2",$games))
{
$description .= "<img src=" http://www.alphaclan.org/Games/Icons/TF2-active.jpg\" alt="Team Fortress 2"> ";
}else
{
$description .= "<img src=" http://www.alphaclan.org/Games/Icons/TF2-inactive.jpg\" alt="Team Fortress 2" > ";
}

if (in_array("Left for Dead",$games))
{
$description .= "<img src=" http://www.alphaclan.org/Games/Icons/L4D1-active.jpg\" alt="Left for Dead"> ";
}else
{
$description .= "<img src=" http://www.alphaclan.org/Games/Icons/L4D1-inactive.jpg\" alt="Left for Dead"> ";
}

if (in_array("Left for Dead 2",$games))
{
$description .= "<img src="http://www.alphaclan.org/Games/Icons/L4D2-active.jpg\" alt="Left for Dead 2"> ";
}else
{
$description .= "<img src="http://www.alphaclan.org/Games/Icons/L4D2-inactive.jpg\" alt="Left for Dead 2"> ";
}

if (in_array("Alien Swarm",$games))
{
$description .= "<img src="http://www.alphaclan.org/Games/Icons/AS-active.jpg\" alt="Alien Swarm"> ";
}else
{
$description .= "<img src="http://www.alphaclan.org/Games/Icons/AS-inactive.jpg\" alt="Alien Swarm"> ";
}

if (in_array("Borderlands",$games))
{
$description .= "<img src="http://www.alphaclan.org/Games/Icons/BL-active.jpg\" alt="Borderlands"> ";
}else
{
$description .= "<img src="http://www.alphaclan.org/Games/Icons/BL-inactive.jpg\" alt="Borderlands"> ";
}



}

//"Steam Profile"
//steam:// an Name anhängen. Online Offline?

/* $content->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY',ar
ray('_GUID'=>'2650660652a01ce39e6085615436f370','TITLE'=>do_l
ang_tempcode('STAFF'),'URL'=>$url,'NAME'=>$name,'DESCRIPTION'
=>$description)));
*/
$content->attach(do_template('ALPHA_ROSTER_LIST',array('_GUI
D'=>'2650660652a01ce39e60856154367450','TITLE'=>do_lang_tempc
ode('STAFF'),'URL'=>$url,'NAME'=>$name,'DESCRIPTION'=>$descri
ption)));


}





$message=get_option('staff_text');
if (has_actual_page_access(get_member(),'admin_config'))
{
if ($message!='') $message.=' ['.do_lang('EDIT').']';
}
$post=comcode_to_tempcode($message,NULL,true);

/*return do_template('INDEX_SCREEN_FANCIER_SCREEN',array('_GUID'=>'3f
b63955b3e1cb1cb4fda2e56b428d08','CONTENT'=>$content,'TITLE'=>
$title,'POST'=>$post,'PRE'=>$pre));*/
return do_template('ALPHA_ROSTER_LIST',array('_GUID'=>'3fb63955b3e1
cb1cb4fda2e56b475d08','CONTENT'=>$content,'TITLE'=>$title,'PO
ST'=>$post,'PRE'=>$pre));
}

/**
* The UI to view a staff member.
*
* @return tempcode The UI
*/
function do_staff_member()
{
require_code('obfuscate');

$username=get_param('id');

breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lan
g_tempcode('STAFF_TITLE',escape_html(get_site_name())))));

$row_staff=$GLOBALS['FORUM_DRIVER']->pget_row($username);
if (is_null($row_staff)) warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
$id=$GLOBALS['FORUM_DRIVER']->pname_id($row_staff);

$title=get_page_title('_STAFF',true,array(escape_html($usern
ame)));

$_real_name=get_ocp_cpf('fullname',$id);
if ($_real_name=='')
{
$real_name=do_lang_tempcode('_UNKNOWN'); // Null should not happen, but sometimes things corrupt
} else
{
$real_name=protect_from_escaping(escape_html($_real_name));
}
$_role=get_ocp_cpf('role',$id);
if ($_role=='')
{
$role=do_lang_tempcode('_UNKNOWN'); // Null should not happen, but sometimes things corrupt
} else
{
require_code('comcode_text');
$role=make_string_tempcode(apply_emoticons($_role));
}
$email_address=obfuscate_email_address($GLOBALS['FORUM_DRIVE
R']->pname_email($row_staff));
$name=$GLOBALS['FORUM_DRIVER']->pname_name($row_staff);
$profile_url=$GLOBALS['FORUM_DRIVER']->member_profile_link($
id);

$all_link=build_url(array('page'=>'_SELF','type'=>'misc'),'_
SELF');

return do_template('STAFF_SCREEN',array('_GUID'=>'fd149466f16722fcb
cef0fba5685a895','TITLE'=>$title,'REAL_NAME'=>$real_name,'ROL
E'=>$role,'ADDRESS'=>$email_address,'NAME'=>$name,'MEMBER_ID'
=>strval($id),'PROFILE_URL'=>$profile_url,'ALL_LINK'=>$all_li
nk));
}

}


Except for a few smaller changes it must be quite familiar ,0)

Anyhow, what i have seen is two things in the template editor:
  1. In the drop down box to add parameters are no parameters listed
  2. There is no button for preview for the template
  3. There is no 'Original' to be found.
I guess i have rather done something wrong with the template than with the php code…
Back to the top
 
Posted
Rating:
#64122
Avatar

STAFF_ALPHA_LIST isn't referenced in that code. That's probably your confusion – you've probably made an edit elsewhere and got muddled up ;).

ocPortal gets the listing of parameters by searching code, I guess it doesn't search custom code. But if you're coding that shouldn't be a problem, you know what parameters you're choosing to pass.

Template previews have to be coded up manually for each template. Again, if you're doing the coding you know where the template is used - I'd just switch between tabs after saving and refresh.


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:
#64124
Avatar

Well-settled

Ok, changed it accordingly - but to no result i guess…

Above i became confused quoting: I created two templates (same contents) but decided on the second naming ALPHA_ROSTER_LIST and quoted the wrong here.. still used the same template.

What i still see is when i go to the linked page that i get my dozens of errors, but also a unformatted list in the content area.. strange enough
Back to the top
 
Posted
Rating:
#64130
Avatar

The template you posted above is based on INDEX_SCREEN_FANCIER_SCREEN not INDEX_SCREEN_FANCIER_ENTRY.


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:
#64131
Avatar

Well-settled

I see... i just checked back with the original file.. i have totally mixed up all original templates inside the script... fixed that and now it works. THanks
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: