Defining a section's name when calling it outside the CMSB

5 posts by 2 authors in: Forums > CMS Builder
Last Post: September 17, 2019   (RSS)

By andreasml - September 17, 2019

Hi

Whenever I call for section within the CMSB I just insert the section name, correct?

For example, if  I want to count the number of record of a section (i.e. "section_name") I run the following script:

<?php
echo mysql_count('section_name');
?>

But, what if I want to call the same script outside the CMSB?  Should I define the section's name using the root directory? For example,

/var/www/vhosts/websiteName.com/httpdocs/cmsb/section_name

Kind regards,

Andreas Lazaris

By daniel - September 17, 2019

Hi Andreas,

mysql_count() is a custom function defined within CMSB, so it can't exactly be used "outside" of CMSB. only be used when the viewer library has been loaded on the page. The viewer library is generated by the Code Generator and generally looks something like this:

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

Are you able to include the viewer library for the script you're writing? If yes, then you can just use the function as normal. If not, you may need to find another way to recreate the functionality - which I also may be able to help with.

Let me know any questions!

Thanks,

Daniel
Technical Lead
interactivetools.com

By andreasml - September 17, 2019

Hi Daniel

First, thank you for your quick reply. Just because I am totally amateur in PHP and programming let me explain to you in detail what is going on.

I have a site named www.vascularregistry.gr. In the root folder of the site (/httpdocs/) I have created the pages of the site. Also, In this root folder I have created another folder named (/registry/) where I have put the CMSB files. So, when I run the CMSB it is within the /registry/ folder. Within this folder (/registry/) i have created some php scripts (with your assistance most of them). For example, one of these scripts is used to count the total number of records within a specific section of the CMSB. This script is the one I have written above. 

Now, what I would like to do is to have the same script running outside the CMSB folder (/registry/) in the pages that exist in the root folder (/httpdocs/). When i use the same php it does function sometimes but some other times it does not. I assume that probably the script is not valid outside the CMSB folder, or for example on this particular php script, it cannot count the number of records of the specific section. 

I am not quite sure if I was clear. I would appreciate it if you gave me a hint.

Kind regards

Andreas

By andreasml - September 17, 2019

Hi Daniel

Thank you very much. I think I got it. I changed the library path and it seems that it works!!

Thanks again for your assistance. Five stars on Interactivetools.com support!!!


Kind regards.

Andreas