Social Engine Q/A

Marco Enrico
2 min readFeb 7, 2020

This post is intended to be some sort of quick reference for SE4 developers. I’ll start off with a few questions and answers. Feel free to leave a question in the comments and I’ll try my best to give you an answer.

In the view how do I get the viewer/subject?

You may use the view helpers viewer and subject. In the view script they are invoked like so: $this->viewer() and $this->subject() respectively. Note that the viewer view helper will return and User_Model_User object even when there isn’t any user logged in. To check if a user is currently logged in check the value of $this->viewer()->getIdentity(). This will return the user_id of the currently logged in user if a user is logged, zero otherwise. The subject view helper will return the subject if set, null otherwise.

Is there an easy way to get a setting in the view?

Yes. You may use the setting view helper to get the value of a setting. In the view script it is invoked this way: $this->settings(‘setting.name’, [default value]). This view helper accepts the same parameters as Engine_Api::_()->getApi(‘settings’, ‘core’)->getSetting(…).

I need the id of the page’s subject for some javascript. Where do I get it?

The id, type and guid of the of subject of a page (if any) is stored in en4.core.subject.

How do I determine which module, controller, and action is rendering a page?

Examine the id attribute of the body element. The value of this attribute is “global_page_<module_name>-<controller_name>-<action_name>.

How do I determine the name of the currently active theme?

Check via the admin panel or examine the class of the body element in any user facing page. The value of this attribute is given as “layout_active_theme_<theme-name>”.

In a fresh install of SE4/SE PHP the css breaks when I try put the site in development mode. What gives?

In some versions of of SE4 the default theme is “Clean”. This theme happens to have a missing image. You can see this message when you view the rendered CSS. To fix this either you remove the offending line or switch to another theme. If you plan on fixing this my removing the offending line, please note that commenting it out with /*…*/ wont work as it is still parsed by SE4.

I added a hidden two hidden form field in a form but only the last one I added is showing up. What’s wrong?

Be sure to set the order option in the in the element parameters. By default all Engine_Form_Element_Hidden have this set to 999. Having the same value for order results in one of them being lost to the void.

Originally published in https://social-engine-tutorials.blogsplot.com.

--

--