Embedding Discourse in an app without custom header


#1

I have my Discourse forums embedded in an iOS app. I have a custom header but I don’t want it visible when viewing in the app. I only want it visible when viewing in Safari. It is possible to do this?


(Руслан Корнев) #2

May I ask you? How did you integrated Discourse in iOS app?


#3

It’s in a UIWebView and I’d like it to display without the header in there.


#4

Well I got it working almost perfectly. I gave the header an ID and hide it using some javascript when the page loads. The only problem with this method is that the header still appears for a second before being hidden.

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
	[webView stringByEvaluatingJavaScriptFromString:@"document.getElementById('my-navigation').style.display = 'none'"];
}

(Руслан Корнев) #5

I’am not an iOS developer, but i think you can achieve this by checking user_agent or screen resolution with Javascript or with CSS using css media by modifying discourse template through admin section.


#6

Does anyone know if there is a way to trigger a different HTML/CSS header through a URL parameter? That would work fine since Discourse doesn’t need to reload the page. The only issue with my solution is that the header is visible for a second before hidden.


(Dean Taylor) #7

Actually the preview URL pretty much does what you are requesting, from /admin/customize/css_html:

http://example.com/?preview-style=dd6fxxxxx-357e-4f17-b710-690bbc2414bd

Try testing that out and see if it fits your needs.

Obviously you wouldn’t need to “Enable” it, just preview.


#8

That seems to work perfect! It works fine without enabling.