Handling javascript and CSS files with IP.Content
Submitted bfarber, Nov 11 2009 05:59 PM | Last updated May 26 2010 09:38 AM
IP.Content is a very flexible system, and as such you have a few options with regards to how you want to handle custom CSS and javascript files when you create pages with IP.Content.
Upload the files and link to them in your page
This is the most basic (and most obvious) method of handling your assets. Using FTP, upload the files to a web-accessible directory on your server, and use normal script and link tags to import the assets into your page. This is a perfectly acceptable method of using assets within IP.Content.
Similarly, you can upload these assets to your Media Manager directory, allowing you to review, move, and delete the files from the ACP at a later point if you want to.
Managing assets as "pages"
IP.Content has built in support for CSS and javascript files, specifically. You can create "pages" in IP.Content, but signal that you want to create a javascript or CSS file instead, by clicking "Add Page" and choosing the appropriate option from the resulting menu. When you do this, you are presented with a much more streamlined form than you see when adding a normal page, because most of those details are irrelevant to a CSS file or a javascript file.
When you create a CSS or Javascript file using the page manager - it doesn't actually create the physical file, but saves it in the database like normal IP.Content pages.
Once you save the new asset file, you can then import it as if it were actually uploaded on disk. For example, if you created a folder "assets" in your IP.Content page manager area, you could create a CSS file under this "assets" folder afterwards, which might have the URL "http://localhost/pag...s/css_file.css" (depending on the URL structure you use and what you called the file). You can get the exact URL by right clicking on the green arrow icon next to the file name, and choosing "Copy Link" or "Copy Shortcut" from the context menu. You then use this URL in your page HTML when you need to refer to the javascript or CSS file. IP.Content will automatically output the correct javascript or CSS content-type headers based on the file type you added.
Neither method is right or wrong, so just go with whichever method you think will be easiest for you in managing your website. If you prefer the ease of managing everything right from your ACP, go right ahead, while those of you who prefer to manage the files by uploading them right to your server through FTP, you're free to do that as well.
Upload the files and link to them in your page
This is the most basic (and most obvious) method of handling your assets. Using FTP, upload the files to a web-accessible directory on your server, and use normal script and link tags to import the assets into your page. This is a perfectly acceptable method of using assets within IP.Content.
Similarly, you can upload these assets to your Media Manager directory, allowing you to review, move, and delete the files from the ACP at a later point if you want to.
Managing assets as "pages"
IP.Content has built in support for CSS and javascript files, specifically. You can create "pages" in IP.Content, but signal that you want to create a javascript or CSS file instead, by clicking "Add Page" and choosing the appropriate option from the resulting menu. When you do this, you are presented with a much more streamlined form than you see when adding a normal page, because most of those details are irrelevant to a CSS file or a javascript file.
When you create a CSS or Javascript file using the page manager - it doesn't actually create the physical file, but saves it in the database like normal IP.Content pages.
Once you save the new asset file, you can then import it as if it were actually uploaded on disk. For example, if you created a folder "assets" in your IP.Content page manager area, you could create a CSS file under this "assets" folder afterwards, which might have the URL "http://localhost/pag...s/css_file.css" (depending on the URL structure you use and what you called the file). You can get the exact URL by right clicking on the green arrow icon next to the file name, and choosing "Copy Link" or "Copy Shortcut" from the context menu. You then use this URL in your page HTML when you need to refer to the javascript or CSS file. IP.Content will automatically output the correct javascript or CSS content-type headers based on the file type you added.
Neither method is right or wrong, so just go with whichever method you think will be easiest for you in managing your website. If you prefer the ease of managing everything right from your ACP, go right ahead, while those of you who prefer to manage the files by uploading them right to your server through FTP, you're free to do that as well.
- Amaranth likes this











0 Comments