WebSite X5Help Center

 
James Becker
James Becker
User

How can I get this code near the top of my page?  en

Auteur : James Becker
Visité 1739, Followers 2, Partagé 10  
Mots-clés :: code,page

How can I get this code near the top of my page?

=========================

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/cofchris/public_html/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  // load records
  list($home_page_leadersRecords, $home_page_leadersMetaData) = getRecords(array(
    'tableName'   => 'home_page_leaders',
    'allowSearch' => '0',
    'loadUploads' => '0',
    'limit'       => '1',
  ));
  $home_page_leadersRecord = @$home_page_leadersRecords[0]; // get first record

  // show error message if no matching record is found
  if (!$home_page_leadersRecord) { dieWith404("Record not found!"); }
?>
==============================

Posté le
3 RéPONSES
BmT 3000
BmT 3000
User

Hello James.

If you want to insert PHP code at line 1 of your page (you cant get closer to the top than that !), select your page (Step 2) click on the Page Properties Icon, Advanced tab.

First, set the File name format to PHP ( a must, when you use php code in a page).

Next, write your code in the Custom code section and finally select Before <HTML> tag, in the drop down menu to the right.

Save and export. V9 will put your lines of php code at the very top of the page. 

B

Lire plus
Posté le de BmT 3000
James Becker
James Becker
User
Auteur

Thanks for the tip. However there is NOAdvanced tab as you mention above. There is however an Expert tab. I clecked it and followed the rest of your tip and it seems to work.

However, I had to go to my server and delete the index.html page other wise the browser always loaded it rather than index.php.

Lire plus
Posté le de James Becker
BmT 3000
BmT 3000
User

Ooops, sorry for the misleading info... I run my software in French, and I confused Advanced and Expert...

Glad to see you founded the right tab. And you did the right thing by deleting index.html, since WX5 does not delete obsolete files.

B

Lire plus
Posté le de BmT 3000