Page 1 of 1

Insert the table view of a table on the home page.

Posted: 2019-11-15 16:31
by fgazza
Hello everyone!
I need help solving this problem:
I would like to insert in the home page of appgini (I refer to the page visible before login and not to the visible one once logged in!) the table view of a specific table visible to people not logged in.

Is there a way to customize the hook file and get this result?

Here is a simulation of what I would like to do:

now:
now.jpg
now.jpg (70.36 KiB) Viewed 8685 times
my goal:
mygoal.jpg
mygoal.jpg (178.5 KiB) Viewed 8685 times
Thanks!

Fabiano

Re: Insert the table view of a table on the home page.

Posted: 2019-11-16 03:08
by ronwill
Is it something like this you are trying to create?

App HOME PAGE:
SharedScreenshot1.jpg
SharedScreenshot1.jpg (50.61 KiB) Viewed 8667 times
I managed this with a small adhoc mod to home.php using an iframe (it would get overwritten unless you make it read only or, as I do, make a saved copy and use file compare after each app generation and copy across the mods again). Plus I add 1 line to header-extras. It seems to work ok in the test I did.

If it's what you are after let me know and I put the details up.

Cheers,
Ron

Re: Insert the table view of a table on the home page.

Posted: 2019-11-16 07:17
by fgazza
Yes! That's exactly what I was looking for! I await the details of the code to implement this solution!
Thank you so much!!!
Fabiano

Re: Insert the table view of a table on the home page.

Posted: 2019-11-16 10:29
by ronwill
Ok, this is what I did (there probably is another other coding way)

MOD to header.php

Code: Select all

<!-- ***** ADD FOLLOWING TO TOP OF HEADER.PHP ***** -->
<style> 
  body {margin-top:-100px !important;}  
  <!-- EFFECTIVELY SHIFTS IFRAME UNDER MAIN HEADER adjust -100px to suit
  Note if you have 'enable zooming' on your table thumbnail image then edit to suit
  making sure pop-up image is not under the showing page header-->
</style>
<style>
  footer {display:none;}
  <!-- might not be needed, worked with/without in my example test -->
</style>
<!-- ***** NOW ADD IFRAME AT LINE 55 BELOW ***** -->
 
<?php 
	if(!isset($Translation)) { @header('Location: index.php'); exit; } 

	$currDir = dirname(__FILE__);
	include_once("{$currDir}/header.php");
	@include("{$currDir}/hooks/links-home.php");

	/*
		Classes of first and other blocks
		---------------------------------
		For possible classes, refer to the Bootstrap grid columns, panels and buttons documentation:
			Grid columns: http://getbootstrap.com/css/#grid
			Panels: http://getbootstrap.com/components/#panels
			Buttons: http://getbootstrap.com/css/#buttons
	*/
	$block_classes = array(
		'first' => array(
			'grid_column' => 'col-sm-6 col-md-4 col-lg-3',
			'panel' => 'panel-warning',
			'link' => 'btn-warning'
		),
		'other' => array(
			'grid_column' => 'col-sm-6 col-md-4 col-lg-3',
			'panel' => 'panel-info',
			'link' => 'btn-info'
		)
	);
?>

<style>
	.panel-body-description{
		margin-top: 10px;
		height: auto;
		overflow: auto;
	}
	.panel-body .btn img{
		margin: 0 10px;
		max-height: 32px;
	}
</style>

<!-- ***** ADD IFRAME IN HERE ***** -->
<iframe src="http://localhost/new_app/table1_view.php" style="border: 0" width="100%"  height="700" frameborder="0" scrolling="auto"></iframe>
<div class="clearfix"></div>
<!-- ***** END OF MOD TO THIS FILE: ADJUST src="YOUR FILE LOCATION" and frame height/scrolling etc to suit your needs
Next see mod to /hooks/header.extras that I use to expand width of iframe/table buttons to
fit screen better ***** -->

<?php
	// get member info
	$mi = getMemberInfo();
MOD to hooks/header-extras

Code: Select all

</div><div class="col-lg-12">
Naturallly the table in iframe will run within the iframe. You can depending on your needs, choose to show or hide the button for the iframe table view on homepage and/or nav menu.

Hope this does what you need.
Cheers, Ron

Re: Insert the table view of a table on the home page.

Posted: 2019-11-16 10:38
by fgazza
Thank you!
I will try it soon and i will let you know if it's good fom me!
Cheers!
Fabiano.

Re: Insert the table view of a table on the home page.

Posted: 2019-12-11 16:15
by onoehring
Hi Fabiano,

I can make another suggestion: Let the admin (or even users) decide, on which page they want to start once they have been logged in.
In /hooks/__global.php you find the necessary function: login_ok (see mine below).

I created a new table tbl_startpages (ID_StartpageNum PK, integer; StartpageURL VARCHAR(200)). There are possible starting pages to which the user will be redirected once logged in.
Another new table tbl_usersettings holds the username and the ID_StartpageNum and assigns each user his own startpage.
Now, the users logged in, I read the settings for this user and redirect to that userpage.

Code: Select all

function login_ok($memberInfo, &$args){		
		//start redirect to defined startpage
		$userpage = sqlValue("Select
		tbl_startpages.StartpageURL
		From
		tbl_startpages Inner Join
		tbl_usersettings On tbl_usersettings.ID_StartpageNum = tbl_startpages.ID_StartpageNum
		Where
		tbl_usersettings.ID_Usersettings = '". makeSafe($memberInfo['username'])."'");
		
		if (isset($userpage) && $userpage != '') 
		{
			return $userpage;
		}
		else
		{
			return '';
		}
		//start redirect to defined startpage	
	}	
tbl_startpages looks like this:
Zwischenablage02.png
Zwischenablage02.png (13.06 KiB) Viewed 8317 times
Olaf