We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

How to: info on main page only? | Forum

Topic location: Forum home » Support » General Questions
David Dec 7 '14

Can anyone please help by advise?

How this possible to output some information in: /master_pages/html_document.html, but on main site page only?

How this possible to make by [if]...[/if] method?

ross Team
ross Dec 8 '14
David, please elaborate what you're trying to achieve so we could assist you better. 
David Dec 8 '14
I need to have for ex. some <div>...</div> in body section in /master_pages/html_document.html and in /master_pages/general.html

And I need it on main page http://www.site.com/index only

By method like this:

{if $mainpage}<div>...</div>{/if}

and this info will be on main page but nowhere else...

2. And I have one more question:

- why it's impossible to use {$siteUrl} and {$siteName} in: /master_pages/html_document.html ?

ross Team
ross Dec 9 '14
html_document.html is just a template of the html page which is used for structuring html code of all html pages. 

General.html page is a structure template of all pages of your website. 

$siteUrl and $sitename are global variables as I said html_document.html is just the structure of all html pages, so in a nutshell it does not understand where to display these variables, you should use them in the general.html file

Mainpage is not a component so you cannot use the if statement and use it as a condition. 

What exactly are you trying to display and where on index page?

The Forum post is edited by ross Dec 9 '14
David Dec 9 '14


Let's talk simplier...

I want to display some <script>...</script> in <head>...</head>.

But I want this script execute on main page only, but on another site pages - NOT.

P.S. I don't know how to explain more simplier )))

ross Team
ross Dec 15 '14
David you need to create a plugin in order to do that which will determine whether this is an index page and include your javascript script which will be located in the static folder of your plugin. 

You can take a look at this method how to include static file: 

protected function newDocument()    {        $language = BOL_LanguageService::getInstance()->getCurrent();        $document = new OW_HtmlDocument();        $document->setCharset('UTF-8');        $document->setMime('text/html');        $document->setLanguage($language->getTag());
        if ( $language->getRtl() )        {            $document->setDirection('rtl');        }        else        {            $document->setDirection('ltr');        }
        if ( (bool) OW::getConfig()->getValue('base', 'favicon') )        {            $document->setFavicon(OW::getPluginManager()->getPlugin('base')->getUserFilesUrl() . 'favicon.ico');        }
        $document->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'jquery.min.js', 'text/javascript', (-100));        $document->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'jquery-migrate.min.js', 'text/javascript', (-100));
        //$document->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'json2.js', 'text/javascript', (-99));        $document->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'ow.js?' . OW::getConfig()->getValue('base', 'cachedEntitiesPostfix'), 'text/javascript', (-50));
        $onloadJs = "OW.bindAutoClicks();OW.bindTips($('body'));";
        if ( OW::getUser()->isAuthenticated() )        {            $activityUrl = OW::getRouter()->urlFor('BASE_CTRL_User', 'updateActivity');            $onloadJs .= "OW.getPing().addCommand('user_activity_update').start(600000);";        }
        $document->addOnloadScript($onloadJs);        OW::getEventManager()->bind(OW_EventManager::ON_AFTER_REQUEST_HANDLE, array($this, 'onBeforeDocumentRender'));
        return $document;    }

As there's index page as it is in Oxwall software.