Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Including custom header and footer: body and head tags removed  (Read 5228 times)

0 Members and 1 Guest are viewing this topic.

flapane

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 251
    • Flavio's page
Including custom header and footer: body and head tags removed
« on: September 09, 2014, 12:06:29 pm »

{CUSTOM_HEADER} is a .php header that contains, among other things, </head> and <body> tags.
{CUSTOM_FOOTER} is a .php footer that contains, among other things, </body> tag.
However, everything is included but those tags (check the link in my signature).

Template.html
Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>{TITLE}</title>
{META}

<link rel="shortcut icon" href="favicon.ico" /> 
{JAVASCRIPT}
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
//-->
</script>

<link rel="stylesheet" href="themes/wooden/style.css" type="text/css" />
<link rel="stylesheet" href="css/coppermine.css" type="text/css" />

{CUSTOM_HEADER}

<div id="content">
<div class="thin">
  <div class="main_column_altra">
<div class="box" id="recommended">
<div class="head colhead_dark">
<h1>{GAL_NAME}</h1></div>
</div>

<div class="box">
  <div class="pad">
<div align="center"><h3>{GAL_DESCRIPTION}</h3></div>
<div id="MENUS">
  <div id="SUB_MENU">
    {SUB_MENU}
  </div>
  <div id="SYS_MENU">
    {SYS_MENU}
  </div>
</div>
{MESSAGE_BLOCK}
<div id="GALLERY">
  {ADMIN_MENU}
  {GALLERY}
  {LANGUAGE_SELECT_FLAGS}
</div>


  </div>
</div>

</div>
</div>

{CUSTOM_FOOTER}

</html>

Any hints?
Thanks in advance

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Including custom header and footer: body and head tags removed
« Reply #1 on: September 09, 2014, 01:43:39 pm »

Please have a look at the function cpg_get_custom_include in include/functions.inc.php:
Code: [Select]
    $return = str_replace('<html>', '', $return);
    $return = str_replace('<head>', '', $return);
    $return = str_replace('<body>', '', $return);
    $return = str_replace('</html>', '', $return);
    $return = str_replace('</head>', '', $return);
    $return = str_replace('</body>', '', $return);
Logged

flapane

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 251
    • Flavio's page
Re: Including custom header and footer: body and head tags removed
« Reply #2 on: September 09, 2014, 04:46:29 pm »

Thanks for your help André.
Of course I can edit the file after every upgrade, but please would you consider adding an option in the control panel to deliberately let those tags appear in the custom includes? A sort of "developer option".
I know those tags shouldn't be there but...  :)

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Including custom header and footer: body and head tags removed
« Reply #3 on: September 10, 2014, 11:31:02 am »

No need for a new option IMHO (however such option should look like and triggered), as you can adjust your theme to don't use that function. Please search for cpg_get_custom_include in themes/sample/theme.php, you'll find it in pageheader(), pagefooter() and pageheader_mini() (currently not sure where the last function is used). Then, replace cpg_get_custom_include with a custom function (e.g. copy cpg_get_custom_include to your theme.php file, rename it to something like cpg_get_custom_include_custom and remove the parts you don't need).
Logged

flapane

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 251
    • Flavio's page
Re: Including custom header and footer: body and head tags removed
« Reply #4 on: September 10, 2014, 08:42:41 pm »

I'm sorry, but I'm not sure I got it.
If I rename
Code: [Select]
cpg_get_custom_include function, I'll of course get a "call to undefined function" error.

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Including custom header and footer: body and head tags removed
« Reply #5 on: September 10, 2014, 08:55:38 pm »

copy cpg_get_custom_include to your theme.php file, rename it to something like cpg_get_custom_include_custom and remove the parts you don't need
Logged

flapane

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 251
    • Flavio's page
Re: Including custom header and footer: body and head tags removed
« Reply #6 on: September 10, 2014, 09:01:26 pm »

Of course... I don't know what I was doing and why. Sorry, I had a tough day.
Pages: [1]   Go Up
 

Page created in 0.024 seconds with 20 queries.