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 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 daniel - September 17, 2019

Hi Andreas,

Thanks for sharing the additional info. I think the issue should be fixable - I'll also try to break down how some of these pieces fit together to give you a better understanding of what's going on.

Firstly, the CMSB code is loaded via the viewer library using the code snippet I included in my last reply. In order to use any CMSB-defined functions (such as mysql_count()) this needs to be present at the top of the file and loading correctly. If the loader is present but the script is not working overall, that indicates a directory issue, as you've suspected.

The loader will do its best to try to find the CMSB app folder by trying some different locations, but this does have some limitations. Primarily, it will only look "up" through a directory path, relative to the PHP file. So for example, if you have CMSB installed to "/public_html/registry/cmsb/" the default loader will work for files in "/public_html/registry/" or "/public_html/registry/subfolder/", etc., but not in "/public_html/" or "/public_html/subfolder/".

It is still possible to load the viewer library in alternate paths, but it does require some small modification to the loader. Given the above example, if we wanted to load it in files outside of "/public_html/registry/" then we'd want to change the first line of the loader from this:

  $libraryPath = 'cmsb/lib/viewer_functions.php';

To this:

  $libraryPath = 'registry/cmsb/lib/viewer_functions.php';

Now, there are a lot of small things that could differ for your specific installation, but I hope the above can get you pointed in the right direction. Though if you find you're still having trouble, feel free to send a 2nd-Level Support Ticket (https://www.interactivetools.com/support/request/) and I can have a look directly.

Thanks,

Daniel
Technical Lead
interactivetools.com

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