Problem with headercontent=true

Discussions on developing plugins for the Cacti Plugin Architecture

Moderators: Developers, Moderators

Post Reply
Rno
Cacti Pro User
Posts: 658
Joined: Wed Dec 07, 2011 9:19 am

Problem with headercontent=true

Post by Rno »

Hello,
I have no clue where to look!

On one of my plugin (MAP, who display a Googlemap or openstreetmap with all device on it) when I call it the first time, it's called with the argument headercontent=true (http://cacti.lausanne.ch/cacti/plugins/ ... ntent=true).
During this first call the map genereated from diffrent call to google is not displayed, I just have a blank page (whell juste the list of TAB and the path of the tab) nothing more.
If I hit F5 i'm able to have all I need, and this time the call to my plugin is without the headercontent=true.

So is anyone able to give me some explanation what is call or not with this headercontent flag ?

And I find that in the response on the browser (F12):
Response has been truncated
Test
Almalinux
php 8.2.14
mariadb 10.6.16
Cacti 1.2.27
Spine 1.2.27
RRD 1.7.2
thold 1.8
monitor 2.5
syslog 3.2
flowview: 3.3
weathermap 1.0 Beta
User avatar
TheWitness
Developer
Posts: 16897
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Problem with headercontent=true

Post by TheWitness »

How do you access it the first time? This variable was introduced to essentially force a page load when you click the top tabs. When you don't click on the top tab, it just does a callback. My guess is that you are injecting css or javascript into the page in your plugin, and as a part of that injection, you are fist checking that the page is in fact the map page. Take out that check to ensure that the injected CSS/JS is on every page, and the problem may go away.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Rno
Cacti Pro User
Posts: 658
Joined: Wed Dec 07, 2011 9:19 am

Re: Problem with headercontent=true

Post by Rno »

So I call it just by clicking on the top tab MAP, and yes that's I can see there is the call with headercontent=true

If I call by typing the URL cacti/plugins/map/map.php it works

Here is what I add to the header to be able to have my map 'working' (using the hook page_head)

Code: Select all

		<style>
		#map-container {
			padding: 6px;
			border-width: 1px;
			border-style: solid;
			border-color: #ccc #ccc #999 #ccc;
			-webkit-box-shadow: rgba(64, 64, 64, 0.5) 0 2px 5px;
			-moz-box-shadow: rgba(64, 64, 64, 0.5) 0 2px 5px;
			box-shadow: rgba(64, 64, 64, 0.1) 0 2px 5px;
			width: 1024px;
		}
		#map {
			width: 1024px;
			height: 768px;
		}
		</style>
	
		<script type="text/javascript" src="<?php print $config['url_path'] ?>plugins/map/markerclusterer.js"></script>
		<script async defer type="text/javascript" src="https://maps.googleapis.com/maps/api/js?<?php ($mapapikey != NULL)?print 'key='.$mapapikey."&":"" ?>callback=initMap"></script>
	
		<script src="https://cdnjs.cloudflare.com/ajax/libs/OverlappingMarkerSpiderfier/1.0.3/oms.min.js"></script>
And I need it, otherwise it's not gona work.
Test
Almalinux
php 8.2.14
mariadb 10.6.16
Cacti 1.2.27
Spine 1.2.27
RRD 1.7.2
thold 1.8
monitor 2.5
syslog 3.2
flowview: 3.3
weathermap 1.0 Beta
User avatar
Osiris
Cacti Guru User
Posts: 1424
Joined: Mon Jan 05, 2015 10:10 am

Re: Problem with headercontent=true

Post by Osiris »

That should work in the modern browser.
Before history, there was a paradise, now dust.
Rno
Cacti Pro User
Posts: 658
Joined: Wed Dec 07, 2011 9:19 am

Re: Problem with headercontent=true

Post by Rno »

For sure, nut it dosen't !

And I can't remove this few line to know what happen, I still no error in the log. it should be something with javascript, but I can't find it
Test
Almalinux
php 8.2.14
mariadb 10.6.16
Cacti 1.2.27
Spine 1.2.27
RRD 1.7.2
thold 1.8
monitor 2.5
syslog 3.2
flowview: 3.3
weathermap 1.0 Beta
Rno
Cacti Pro User
Posts: 658
Joined: Wed Dec 07, 2011 9:19 am

Re: Problem with headercontent=true

Post by Rno »

So finaly I find the issue, but I had to use Chrome to gime me an error.
it was initMap not a function
and here here how I solve it.
https://stackoverflow.com/questions/324 ... a-function

I apply proposition 2 and it works.
Test
Almalinux
php 8.2.14
mariadb 10.6.16
Cacti 1.2.27
Spine 1.2.27
RRD 1.7.2
thold 1.8
monitor 2.5
syslog 3.2
flowview: 3.3
weathermap 1.0 Beta
User avatar
Osiris
Cacti Guru User
Posts: 1424
Joined: Mon Jan 05, 2015 10:10 am

Re: Problem with headercontent=true

Post by Osiris »

Cool!
Before history, there was a paradise, now dust.
netniV
Cacti Guru User
Posts: 3440
Joined: Sun Aug 27, 2017 12:05 am

Re: Problem with headercontent=true

Post by netniV »

I removed the need for this daft flag in 1.3 dev
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest