CakePHP: keeping view files in same directory - html

For controller_A's views, I currently use $this->element('repeatedly_used_html'); in the element folder for some .ctp files that are used more than once. However, some of the files in the element folder are entirely used for one controller, and the file are unorganized in the element folder.
So, for exmaple, controller_A has views that use files from the element folder. I would like these .ctp files for controller A's views to be contained in the app/views/A.. is there way to invoke a call similar to $this->element('repeatedly_used_html'); that will allow me to keep files the folder app/views/controller_A? I would like to avoid writing a very long .ctp file.

It looks like you're using CakePHP 1.3 based on your directory structure. If this is the case, you can do this by simply using the render() method instead of element(). This will render a template using the current view path (in this case, the controller you're in).
echo $this->render('repeatedly_used_html', false);
The second parameter is the layout, which we set to false to make sure the whole layout isn't rendered along with the view.

echo $this->element( 'subfoldername/viewfile' );
Then create the subfoldername directory in your elements folder.

Related

Relative path in dynamically generated (with hash) folder

With Express, I am trying to acess relative path (css/..., assets/...) inside HTML file.
I can't use express.static() because the HTML file is located in a dynamically generated folder, with a hash as its name.
There are many folders with a different set of files inside, these folders are in "public/assets/template/file/tmp".
The server is trying to access these files based on what was defined in express.static, which was "path.join(__dirname,'public')", in order to handle other files in the project.
The public folder (which is in the project root) looks like this:
The index.html head:
I couldn't think of anything to do in this current situation, perhaps set a different express.static when accessing files in the dynamically generated folder, but it doesn't look like the best approach (not even sure if it's possible).

How can I retrieve the the current CSHTML file for more intelligent view selection?

Suppose I have a partial view "_Navbar.cshtml" in my Views/Shared folder that's referenced in a layout page... so it gets embedded on every page.
Now, suppose I have a view with the same name existing in my Views/ControllerX/Partial folder, which is a navigation bar specific to that view.
In this case, views in other controllers find the Shared partial view file fine. However, when I run a view in ControllerX, the _Navbar.cshtml file in Views/ControllerX/Partial ends up usurping/overriding the one in Shared/Views.
So I was wondering if there's a way to prefer a view based on the currently executing cshtml file. For example, if "Partial" is called from a cshtml file in the Shared folder, then it should prefer other partial views in that same folder over ones in more specific controller view locations.
In short, is there a way to rig the view engine so that rather than having a static search path order, it's contextual and looks for files in the same folder as the executing cshtml file first?

Action script trees

i have a directory path of the computer and i will like to create a tree of that directory path.
For example, If i have a directory path of the desktop, i will like to create a tree of all the folders in the desktop and the subfolders.
The only way i can think of is to create a fileSystemTree object and set the directory to the path i want. If i were to set the directory as Desktop, it immediately show the folders under the desktop directory and not the Desktop root folder first.
So you'll need to use Tree control.
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7d80.html
The trick is going to be adding the child nodes at runtime upon clicking open. A dataProvider has several methods that you implement on a dataProvider for retrieving the children. That's not to hard by creating your own dataProvider, but that's the first step. Write a FileCollection that conforms to the model. Read the manual and it should be pretty easy.

Recursively navigate a directory generating dynamic xml files according to the current visited folder with SSIS

I need to visit a folder and all of its children with SSIS (SQL Server Integration Services). At the moment by setting the folder path into a variable after reading it, I able to loop through all the .txt files of the current folder and fill a pre-generated (with head info) xml file.
What I would need now is to be able to create one per each accessed folder, a new xml file (the beginning content will be always the same). Once I would be able to create it, as first action once a new folder is accessed, I can then simply apply the logic I developed so far.
However I am blocked at the moment, since within the loop where i read the files (with their full path) I cannot find a way to express "create the xml file if the accessed folder is new".
Assuming I understand the problem, you need to walk the entirety of a directory structure and for each folder you find, you need to create a base XML file. Then for each text file you find in that folder, you will perform some operation on the XML file. The trick being how do you only create the XML file once.
I would envision a process like this.
A script task that makes use of the System.IO.GetDirectories to populate a variable (directoryXML> that contains the folder structure, something like
<Dir>
<D>C:\ssisdata</D>
<D>C:\ssisdata\a</D>
<D>C:\ssidata\a\b</D>
</Dir>
Use a Foreach Nodelist Enumerator to shred that XML out into a variable (currentDirecotry).
You'd perform your one-time task of creating the XML file in currentDirectory.
Further using the currentDirectory variable as an expression on the Foreach File Enumerator (assign to Directory with a FileSpec of *.txt) you can then perform your task on all the files meeting that specification. Do not check the traverse subfolder option as that will not give the desired results.
This is a fairly high level approach to the problem as I'm assuming you have some familiarity with SSIS but the approach should be sound. Let me know if you have any particular sticking points.

customizing `org-publish-project-alist`

I'm trying to publish webpage using org-mode. Two questions:
Is there a way to "sync" the org-mode files in the base-directory and the html files in the publishing-directory? Specifically, if I delete an org file in the base-directory, can I get org-publish-html to delete the corresponding file in the html directory also?
If I have pages within subdirectories, how can I specify a single .css file in the root directory to be used for the style sheet? For instance, my directory structure is as follows:
public_html/
css/
mystyle.css
index.html
subdir/
index.html
With the following specifications in org-publish-project-alist (this is just a subset) --
:publishing-directory "public_html"
:style "<link rel=\"stylesheet\" href=\"css/mystyle.css\" type=\"text/css\"/>"
mystyle.css is used by public_html/index.html but not by public_html/subdir/index.html. Is there a simple remedy to this (I want the style sheet to be used by both/all files in subdirectories)?
Thanks much ~
There is no straightforward way of doing this. Org-mode doesn't know (or care) about the location to which it is publishing - it just sends things there and makes sure the correct directory structure exists. There is a hook in the publishing process that gets called after the files have been pushed to their published location. This is controlled by setting the :completion-function property in your org-publish-project-alist. You could use this hook to write a function that compares the *.org files in your base-dir and subdirectories to the accompanying *.html published files, and remove those *.html files that don't have an accompanying *.org file.
I suspect this will be most easily accomplished by making your Lisp completion-function call a shell script that removes the necessary files. If you are doing something fancy with the :include, :exclude, or :base-extension properties, you'll likely want your completion-function to grab the pertinent information from the plist and then pass them to your shell script. This org-mode page has an example completion-function that shows how to get property values for the org-publish-project-alist. You would then need to pass them to your shell script.
There are several ways to do this. Perhaps the simplest is to just override the default style sheet in each file with a line such as:
#+STYLE: <link rel="stylesheet" type="text/css" href="../stylesheet.css" />
for your first level of subdirectory files, and keep adding ../ as you get deeper in the directory structure.
Another possibility is generate generic template files for each level within the directory tree. This org-mode page gives a nice example of how to set this up.
Lastly, another option is to use the :preparation-function property of org-publish-project-alist to define a function that will automatically change the style file for each file. Again, this is probably best done by having the Lisp preparation-function call a shell script to parse the files. I could imagine doing this with the Unix sed program to find a regular expression denoted something like href="#MYLOC#/stylesheet.css" /> and substitute the stuff between #'s with the appropriate level within the directory tree. This seems like overkill, given the other options.