Can a file be conditionally included in includes.xml?
#1
I'd like to conditionally include a whole file in includes.xml. What is the proper way to do this?

Should something like this work?
PHP Code:
<include condition="Skin.HasSetting(foo)" file="foo.xml" /> 
Reply
#2
What's wrong with just including it as normal?

<include>foo.xml</include>

You could always try it and see if it works but the correct format is this -

<include condition="Skin.HasSetting(foo)>foo.xml</include>
Reply
#3
Memory conservation is the only reason. Trying to remove 1 or 2 megs worth of code for all the different views. The plan was to conditionally include only the file with the code needed for the active view.

I tried <include condition="Skin.HasSetting(foo)">foo.xml</include> and it didn't work.

I also tried <include>foo.xml</include> and that didn't work either.
Reply
#4
So, I can't conditionally include whole files but I can get an include from a file that isn't in inlcudes.xml:
PHP Code:
<include condition="Skin.HasSetting(foo)" file="foo.xml">foobar</include> 
This is probably better than what I wanted to do in the first place.

Figured this out by browsing through the source code and reading the comments on the code here: https://github.com/xbmc/xbmc/blob/master...cludes.cpp

I didn't see anything in the wiki about being able to get includes this way. Maybe I'll add it if I have some spare time.
Reply
#5
Question. Why does eliminating 617kb worth of seperate files from my includes.xml free up almost 4MB worth of RAM? Does it have something to do with includes within includes within includes?
I N C L U C E P T I O N
Reply
#6
Using includes to reduce the same code is only really there to help the skinner, when it's all loaded by XBMC each include gets written in full.
Reply
#7
wannabegt4 Wrote:So, I can't conditionally include whole files but I can get an include from a file that isn't in inlcudes.xml:
PHP Code:
<include condition="Skin.HasSetting(foo)" file="foo.xml">foobar</include> 
This is probably better than what I wanted to do in the first place.

Figured this out by browsing through the source code and reading the comments on the code here: https://github.com/xbmc/xbmc/blob/master...cludes.cpp

I didn't see anything in the wiki about being able to get includes this way. Maybe I'll add it if I have some spare time.

Interesting find but surely XBMC has got to somehow read and store the info on the non-included file to be able to use the include found in it?
Reply
#8
Hitcher Wrote:Interesting find but surely XBMC has got to somehow read and store the info on the non-included file to be able to use the include found in it?
only difference will be when we load that file - if we use <include file="xxx.xml" /> in includes.xml it will be loaded when initialize skin. if it will be used in window/dialog xml via <include file="xxx.xml" [condition="yyy"]>name_of_include</include> then this file will be loaded when xbmc first time will activate that window/dialog (condition doesn't matter yet). So it doesn't matter that much - use method that You're comfortable with and keep Your xmls organised.
Always read the XBMC online-manual, FAQ and search the forums before posting.
Do NOT e-mail Team-XBMC members asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting, make sure you read this first

My previous forum/trac nickname: grajen3
Reply
#9
Thanks for the explanation.

One more question - once said include is loaded I guess it will then stay in memory until XBMC is reloaded.
Reply
#10
Hitcher Wrote:Thanks for the explanation.

One more question - once said include is loaded I guess it will then stay in memory until XBMC is reloaded.
yes, we keep all includes in memory utill we unload skin (exit xbmc / reload skin / change skin)
Always read the XBMC online-manual, FAQ and search the forums before posting.
Do NOT e-mail Team-XBMC members asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting, make sure you read this first

My previous forum/trac nickname: grajen3
Reply
#11
Hitcher Wrote:Thanks for the explanation.

One more question - once said include is loaded I guess it will then stay in memory until XBMC is reloaded.

I'm pretty sure you're reffering to what Jezz_X posted in this thread http://forum.xbmc.org/showthread.php?tid=64971.

Everything in my experience with inludes so far points to this being true. All of includes.XML and any file that it includes are held in memory at skin load. I've freed up 4MB worth of RAM throughout the whole skin by removing 600k worth of code with several nested includes.
Reply

Logout Mark Read Team Forum Stats Members Help
Can a file be conditionally included in includes.xml?0