Hide some div's from Group visitor

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
User avatar
Jay Webb
Veteran Member
Posts: 80
Joined: 2017-08-26 15:27
Contact:

Hide some div's from Group visitor

Post by Jay Webb » 2020-05-18 21:53

I'm using appgini 5.82

Hello:
I'm trying to hide some div's that I have in templates/individuals_templateDV.html from group visitor.
Div's are #non, #positive, #rfresh,

I'm using code from post viewtopic.php?t=465
I have this code in my footer-extra.php

Code: Select all

<?php
	$memberInfo = getMemberInfo();
		if($memberInfo['group'] !='visitor'){
?>
<script type='text/javascript'>
	document.observe("dom:loaded", function() {
		$j('#non, #positive, #rfresh').hide();
			});
</script>
<?php
}
?>
It works, but the problem is it hides the div's for all groups when it's only group visitor that's coded for.
I tried adding a esle statement

Code: Select all

<?php
	$memberInfo = getMemberInfo();
		if($memberInfo['group'] !='visitor'){
?>
<script type='text/javascript'>
	document.observe("dom:loaded", function() {
		$j('#non, #positive, #rfresh').hide();
    }else{
			  $j('#non, #positive, #rfresh').show();
		});
</script>
<?php
}
?>
but that didn't work, showed div's back for all groups.
90% of the time I can figure it out, but it's the other 10% I spend hours and hours stumped.
Not sure how to move forward or what's missing.
What we envision, we make happen.

User avatar
Jay Webb
Veteran Member
Posts: 80
Joined: 2017-08-26 15:27
Contact:

Re: Hide some div's from Group visitor

Post by Jay Webb » 2020-05-19 00:19

Yep ee, got it working, jumped from the foot-extra.php and used the hooks/TABLENAME.php file
forked the code

Code: Select all

	function individuals_dv($selectedID, $memberInfo, &$html, &$args) {

if(isset($_REQUEST['dvprint_x'])) return;
		
		ob_start(); ?>
		
		<script>
		
		<?php if ($memberInfo['group'] == 'Visitor' ){?>

			$j(function(){
			
			$j('#non, #positive, #rfresh').hide();

			}); 
				
			    
		<?php }else{; ?>
		
			$j(function(){
			
			$j('#non, #positive, #rfresh').show();

			}); 
				
				
		<?php }; ?>
					
			
		</script>
		
		<?php
		$form_code = ob_get_contents();
		ob_end_clean();
		
		$html .= $form_code;

	}
and that did the trick
What we envision, we make happen.

Post Reply