WebSite X5Help Center

 
James Becker
James Becker
User

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

Author: James Becker
Visited 1728, Followers 2, Shared 10  
Tags: 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!"); }
?>
==============================

Posted on the
3 ANSWERS
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

Read more
Posted on the from BmT 3000
James Becker
James Becker
User
Author

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.

Read more
Posted on the from 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

Read more
Posted on the from BmT 3000