Call to a member function get() on null #45

Closed
opened 2017-02-26 00:07:56 +00:00 by mwweb · 7 comments
mwweb commented 2017-02-26 00:07:56 +00:00 (Migrated from github.com)

I'm baffled on this one. I have several site views, and most do some form of get from the component parameters. They all appear to work, except one view. Below is a sample of the code, and this is failing the <?php if($this->params->get('show_state_title') == '1'){?>, generating a Call to a member function get() on null. I've compared to my other views, and some from Sermon Distributor, and can't see any issues. I have also checked my parameters, and the parameter is in the code.

Have you ever encountered an issue like this, or have any thoughts as to what to look at?

<?php echo $this->toolbar->render(); ?> <!-- Single state view start -->
<div class="g-content">
    <?php if($this->params->get('show_state_title') == '1'){?>
    <div class="platform-content row-fluid">        
        <div class="span12">
            <h3 class="g-title"><?php echo $this->state->name; ?></h3>
        </div>        
    </div>
    <?php } ?>
I'm baffled on this one. I have several site views, and most do some form of get from the component parameters. They all appear to work, except one view. Below is a sample of the code, and this is failing the` <?php if($this->params->get('show_state_title') == '1'){?>`, generating a Call to a member function get() on null. I've compared to my other views, and some from Sermon Distributor, and can't see any issues. I have also checked my parameters, and the parameter is in the code. Have you ever encountered an issue like this, or have any thoughts as to what to look at? ``` <?php echo $this->toolbar->render(); ?> <!-- Single state view start --> <div class="g-content"> <?php if($this->params->get('show_state_title') == '1'){?> <div class="platform-content row-fluid"> <div class="span12"> <h3 class="g-title"><?php echo $this->state->name; ?></h3> </div> </div> <?php } ?> ```
Peeripapo commented 2017-02-26 09:57:26 +00:00 (Migrated from github.com)

Are you hiding the "<?php" on purpose or is it missing?

Are you hiding the "<?php" on purpose or is it missing?
mwweb commented 2017-02-26 18:01:42 +00:00 (Migrated from github.com)

Grrr. It stripped out some of the coding when I posted. Here it is again attached, since it keeps stripping out the code, even when using the code tags.

<?php echo $this->toolbar->render(); ?> <!-- Single state view start -->
<div class="g-content">
    <?php if($this->params->get('show_state_title') == '1'){?>
    <div class="platform-content row-fluid">        
        <div class="span12">
            <h3 class="g-title"><?php echo $this->state->name; ?></h3>
        </div>        
    </div>
Grrr. It stripped out some of the coding when I posted. Here it is again attached, since it keeps stripping out the code, even when using the code tags. ``` <?php echo $this->toolbar->render(); ?> <!-- Single state view start --> <div class="g-content"> <?php if($this->params->get('show_state_title') == '1'){?> <div class="platform-content row-fluid"> <div class="span12"> <h3 class="g-title"><?php echo $this->state->name; ?></h3> </div> </div> ```

Well without seeing the rest of the code from the model->view.html.php->view it is very hard to debug...
All I can think is that you somewhere above this code overwritten $this->params somehow...

So take a look at that, then also insure that you make use of the better method instead of the } use :

Like so:

<?php echo $this->toolbar->render(); ?> <!-- Single state view start -->
<div class="g-content">
    <?php if($this->params->get('show_state_title') == '1') :?>
    <div class="platform-content row-fluid">        
        <div class="span12">
            <h3 class="g-title"><?php echo $this->state->name; ?></h3>
        </div>        
    </div>
    <?php endif; ?>
</div>
Well without seeing the rest of the code from the `model->view.html.php->view` it is very hard to debug... All I can think is that you somewhere above this code overwritten `$this->params` somehow... So take a look at that, then also insure that you make use of the better method instead of the `}` use `:` Like so: ``` <?php echo $this->toolbar->render(); ?> <!-- Single state view start --> <div class="g-content"> <?php if($this->params->get('show_state_title') == '1') :?> <div class="platform-content row-fluid"> <div class="span12"> <h3 class="g-title"><?php echo $this->state->name; ?></h3> </div> </div> <?php endif; ?> </div> ```
mwweb commented 2017-02-27 20:24:50 +00:00 (Migrated from github.com)

This was really "weird", but your statement about model->view.html.php, got me looking at the file, and found that the following isn't being added to function display($tpl = null)

	// get combined params of both component and menu
	$this->app = JFactory::getApplication();
	$this->params = $this->app->getParams();
	$this->menu = $this->app->getMenu()->getActive();

Because that didn't get added to the code for some reason, once all instances of $this->params was changed to $this->state->params then it started working. It's a work around so I can finish working on this view, but still doesn't explain why that code didn't get added.

This was really "weird", but your statement about model->view.html.php, got me looking at the file, and found that the following isn't being added to function display($tpl = null) // get combined params of both component and menu $this->app = JFactory::getApplication(); $this->params = $this->app->getParams(); $this->menu = $this->app->getMenu()->getActive(); Because that didn't get added to the code for some reason, once all instances of $this->params was changed to $this->state->params then it started working. It's a work around so I can finish working on this view, but still doesn't explain why that code didn't get added.

That is not possible... the view.html.php for site views are build from these two files

And as you can see those lines are hard coded into the file, so you will need to check those files in your local install to see if they were changed.

That is not possible... the view.html.php for site views are build from these two files - [JViewLegacy_site.php](https://github.com/vdm-io/Joomla-Component-Builder/blob/master/admin/compiler/joomla_3/JViewLegacy_site.php#L43) - [JViewLegacy_list_site.php](https://github.com/vdm-io/Joomla-Component-Builder/blob/master/admin/compiler/joomla_3/JViewLegacy_list_site.php#L43) And as you can see those lines are hard coded into the file, so you will need to check those files in your local install to see if they were changed.
mwweb commented 2017-02-27 20:51:29 +00:00 (Migrated from github.com)

They don't show as changed, when copying the code from Github and comparing to localhost version. It may not be possible, but it is doing this. Here is the last push of the code that I submitted to my bitbucket repository.

8f335f4140/site/views/state/view.html.php?at=default

They don't show as changed, when copying the code from Github and comparing to localhost version. It may not be possible, but it is doing this. Here is the last push of the code that I submitted to my bitbucket repository. https://bitbucket.org/mostwantedweb/most-wanted-real-estate-v2/src/8f335f41407ccfcd7018c730f965fec8808cc322/site/views/state/view.html.php?at=default
ro-ot commented 2017-02-28 12:56:48 +00:00 (Migrated from github.com)

Hey but that code is in that repos, so what is the issue?

Hey but that code is in that repos, so what is the issue?
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#45
No description provided.