Coldfusion CFC Mapping to external directories with CFCs that reference other folders - coldfusion

I've done some poking around and trial and error but I'm not coming up for a solution to this problem I have.
I have a folder structure like this (example)
Application.cfc
Objects\
Object.cfc
Utilities\
Util.cfc
API\
Resources\
index.cfm
Application.cfc
I have one site that points to the API folder (http://api.site.com) and another that points to the overall root (http://site.com)
From Api\Resource\index.cfm. I'm trying to createObject() on Objects\Object.cfc. I set up a mapping, either in CF Admin, or API\Application.cfc with this.mappings["/SiteRoot"] = "C:\wwwroot". Inside the index.cfm I do createObject("component","SiteRoot.Objects.Object"). This correctly access the Object.cfc.
The issue I'm having is that it fails because Object.cfc instantiates the Utilities\Util.cfc just by createObject("component","Utilities.Util"). The error is that Utilities.Util cannot be found.
There are other files in the very bottom root that can obviously call Object.cfc with no problems since it just goes into the Utilities folder naturally.
Any suggestions Or do I really need to just break the API Folder out of this root entirely?
Thanks!
UPDATE
It's not letting me answer my own question just yet but I wanted to post here before others chimed in.
Despite reiniting the application and restarting the application server, once or twice it wasn't working. Then suddenly, it just went and worked as I would have expected. Object.cfc could find Util.cfc correctly based on it's relative path.
I gave upvotes to those who responded as they were perfectly viable alternatives and solutions and would have gone with one of them had this not just started working. Demons, I tell you. Demons.
Thanks!

I think I would change your second create object call (the utilities one) to createObject("SiteRoot.Utilities.Util") ? Making sure that one mapping "governs" the starting point for all the objects no matter where instantiated.

If you really cannot change your code then just create a ColdFusion mapping called Utilities pointed at the Utilities folder.

Related

Move the storage directory outside of the web directory

In opencart version 3 there is a notification:
It is very imporant that you move the storage directory outside of the
web directory (e.g. public_html, www or htdocs)
Screenshot
I tried by clicking on move button in the picture also tried manually but after trying it is giving weird errors.
You can move storage directory outside of the web directory (e.g. public_html, www or htdocs) in three ways
Automatically Moving
Manual Moving (from admin panel)
Manual Moving ( By editing Config files)...
Assuming that you know first and second methods.Here I will explain the third method to you.
Copy your storage directory from system/storage to public_html, www or htdocs.
Change the following file path from both config files i.e. config.php and admin/config.php as shown below.
define('DIR_STORAGE', 'public_html/storage');
Please replace public_html to your desired path.
I hope this answer might help you.
It is very simple to remove / hide this dialog box:
open 'admin/controller/common/dashboard.php' file
search below line
$data['security'] = $this->load->controller('common/security');
and replace it with below line
$data['security'] = '';
That's it :)
Change directory path as decribed abowe--but when You save the config.php use utf8 encoding. I have worked 2 hour on it- did everithing i found on google, but nothing worked. Just this simple thing!
I also ran into this little problem, and the fault was layer 8 (problems between the keyboard and the chair)
I hadn't read the code that I had to change correctly and I was doing it wrong, I'll explain better in case someone runs into the same problem:
capturing the variable to be deleted
I was just replacing the new directory path, not removing the DIR_SYSTEM variable.
you have to delete DIR_SYSTEM and place the new route. that's all.
For this reason it gave me an error and so I came to this post.
It is my first contribution. I hope this helps you.

How do I track down specifics for an opencart module that is rendering on my site but missing everything except the catalog template file?

I've inherited an opencart 1.5.5.1 site and am completely new to the cms. From what I've been able to gather, it was built by a competent developer but then went through a hack-it-up development team, and then on to me. So, I really don't know what all to expect from it.
I currently have a module that is rendering in the left sidebar and I don't know why it's rendering there. The only file I can find in the file stack related at all to this "module" is a single template file within the catalog directory structure called:
/catalog/view/theme/mytheme/template/module/affiliate_profile_select.tpl
All of the other installed modules on the site seem to have lots of other files associated with them, whose locations are verified by the research I've done on creating opencart modules: ie, module files in the following directories:
/catalog/controller/module/
/catalog/language/english/module/
/catalog/model/module/
/catalog/view/theme/mytheme/template/module/
/admin/controller/module/
/admin/language/english/module/
/admin/model/module/
/admin/view/template/module/
From what I've been able to find though, this single file (affiliate_profile_select.tpl) is the only file in the file stack that is associated with this module.
I can't find anything related to this module, and/or file, inside any of the vqmod php or xml files.
I can't find anything related to this module in the admin area. I've tried searching through all of the installed modules for other generic identifiers (the section view is rendering at the very top of the left-sidebar on most non-logged-in pages, so I'm looking for layout locations of "Left Sidebar" and positions less than 2), but haven't found anything.
And yet, the section is obviously rendering on the site, so it has to be there somewhere. In fact, it's rendering in two places. It's also in the top-content section of the mobile view of the home page.
Right now it's almost feeling like it was a module that had been written, installed, and configured, and then someone deleted all but one of the files associated with the module. Could a situation like that happen?
Is there any way to track this issue down by querying the database? Or would the template inclusion obviously be inside a file somewhere and I just need to find it? To complicate matters, the hosting company doesn't allow remote login with a console (from what I can tell). Otherwise I'd just have run a grep for the filename in case someone had just thrown an "include()" statement in somewhere. The only place I've checked for something like that so far was in the left-sidebar template file:
/catalog/view/theme/default/template/common/column_left.tpl
but it's just a simple for-loop that echoes out the module views.
Any help or direction on how I might be able to track this problem down would be of significant help.
In Opencart, .tpl (template) files are always called by controllers which as you probably guessed are in catalog/controller/. An if it's a module (showing in left sidebar position, it's probably going to be in catalog/controller/module/. First order of business would be to find the controller that's calling the template you referred to. I'd probably start by getting into a shell and doing something like this from the site's docroot:
grep -r affiliate_profile_select .
From there you should be able to find the associated module controller and any other logic involved. Sometimes people use vQmod to add something on to a pre-existing module so that can possibly explain the lack of other similarly named files.

Can't refresh CFC CF9 when using an application.cfm

I was charged with making some modification to an old application, and I created a new page which was being passed a URL parameter page_name, which is a you guessed it a name of a page with .cfm appended. So, in my haste, I continued using it, and was building out my CFC and using the page_name as the identifier for a record. Then I realized that there is a possibility of that name being duplicated in the table, and changed that url parameter to use the page_id, which is unique. I modified my CFC to use the new key, and nothing worked. So I started going through my code and figured I made a typo, started commenting things out, and finally dumped out my CFC object and voila, none of the edits I made were actually being used. This was fairly obvious, since page_name was a string, and page_id was numeric.
So I started googling,The first thing I saw as adjust things in the CFAdmin. I don't have access to it, and restarting the server isn't an option since I'm using an RDS to live code. The next thing I tried was to add applicationStop(), onApplicationStart(), to my Application.cfc. Well the problem is that the Application.cfc, is actually an Application.cfm. So after fiddling with the <cfapplication ... > tag, and nothing being updated, I'm here asking for help.
So is there a quick fix for this? Should I go ahead and create an application.cfc? I hope I explained myself, and sorry for all the text.
Confirm that your cfc is bound to either the session or application scope.
If it is, then you can rename the application in application.cfm and it will reset the object.
If your cfc is NOT bound to session or application scope, you have a cacheing issue. You need to go the the CF admin -> Server Settings -> Cache tab and uncheck component cache and possibly some others.
For further recommendations, ColdFusion Components Inheriting Functions Of Others
Sounds like you have been painted into a corner. Last option IF you have access the the server it self and can get into the C:\ or whatever drive that ColdFusion have been installed on, you can just manually delete the generated Java Class files that the server is using that has the old code. When ColdFusion sees there is no Class file it will recompile the newly changed file and whoa black betty go bam-a-lam your changes will be in production.
For more information here is an posting you can read up on: http://kalyan-coldfusion.blogspot.com/2010/08/how-coldfusion-works-and-its-key.html
Cheers

Cannot find CFML template for custom tag

I am not a ColdFusion coder. Doing a favor for a friend who ported his CF site from a Windows server to Unix on GoDaddy.
Site is displaying error:
Cannot find CFML template for custom tag jstk. ColdFusion
attempted looking in the tree of installed custom tags but did not
find a custom tag with this name.
The site as I found it has at document root /CustomTags with the jstk.cfm file and a set of files in cf_jstk
My Googling located this:
You must store custom tag pages in any one of the following:
The same directory as the calling page;
The cfusion\CustomTags directory;
A subdirectory of the cfusion\CustomTags directory;
A directory that you specify in the ColdFusion Administrator
So I have:
Tried creating placing /CustomTags in /cfusion/CustomTags
Tried copying /cfusion/CustomTags to above document root
Tried copying jstk.cfm and subfolders into same directory as calling file(index.cfm)
Update: Per GoDaddy support I have also tried adding the following to no effect: <cfmodule template="CustomTags/jstk.cfm">
Can any one give me some tips on this or should I just tell my guy to look for a CF coder?
Thanks!
I don't know how GoDaddy is setup, so as a quick test, please do the following:
Create file test.cfm in the webroot with contents:
<cf_testtag/>
<cfoutput>test</cfoutput><cfabort/>
Create file testtag.cfm in the webroot with contents:
<cfdump var=#ThisTag# />
Then in a browser visit the test.cfm page.
You should get two debug dumps, followed by the 'test'; this will confirm that custom tags in general are working.
If that works move the testtag.cfm to the CustomTags directory, and see if you get the same behaviour or an error.
If this produces an error, for CF8 and above, you can add <cfset This.CustomTagPaths = "/CustomTags" /> inside the Application.cfc file (assuming there is a App cfc and not an Application.cfm) to ensure that directory is checked for tags.
It is possible to convert Application.cfm to Application.cfc - how easy this is depends on how complex the code is in there - might be something you could figure out, or might need an experienced CF dev, it depends.
Depending on the outcome of this, we can attempt to debug why the jstk tag isn't working (unless one of the above solves it).
In an effort to check the simple things before worrying about complex things:
Remember that filenames on *nix systems are case sensitive, but on windows are not.
For example, a windows server will pick up "application.cfm" but a linux server won't. It requires "Application.cfm".
Check to make sure all filenames/paths are the correct case.
Normally, CFML check every custom tags in current directory first, if not found, second is in CFMX8/customtags/.

Magento - locate specific core files

I am familiar with theming and using template hints in the Magento back office to locate .phtml files.
What I am not really familiar with are the core files such as app/code/core/Mage/Catalog/Model
What I need to do is override a core file like I would a core phtml file by copying it to 'my theme'.
I basically want to amend some labels which appear on the order summary page of the Magento checkout process - domain.com/checkout/cart/
I followed the trail to the phtml files using template hints. Within the app/design/frontend/default/mytheme/template/checkout/cart I found the code
renderTotals(); ?>
Now I managed, by accident, to stumble upon two of the files I wanted to change:
/httpdocs/app/code/local/Mage/Sales/Model/Quote/Address/Total/Grand.php
/httpdocs/app/code/local/Mage/Sales/Model/Quote/Address/Total/Shipping.php
I made local copies of these files (http://www.magentocommerce.com/wiki/how_to/how_to_create_a_local_copy_of_app_code_core_mage) to override the default labels, like I would if I was overriding a template file.
My question is, how can you locate core files which pertain to the 'stuff' you want to change, located in function calls such as renderTotals(); ?> in the phtml files?
Not being able to pinpoint stuff like I can with template hints is slowing me down, and I am struggling to find a solution as I am not up on all the vocab surrounding Magento yet.
Hope this makes sense and thanks in advance!
From the same settings page where you turn on Template Path Hints, also turn on the "Add Block Names to Hints" setting. This will show you PHP class names such as: Mage_Sales_Model_Quote_Address_Total_Grand to which you can deduce the folder path (underscores represent a subfolder, and the last piece represents the file name).
If you're getting a block such as Mage_Sales_Model_Quote_Address_Total_Default then sometimes it just takes a little common sense to see that it's pulling in other files from the same folder (such as Grand.php and Shipping.php). But there are generally only a couple files in the same folder, so this is pretty easy to see.
As Sid Vel said, a good Search Project functionality is helpful. But if you find yourself looking at Abstract.php of some class, often you need to look in a subfolder in that directory with the proper name to find the concrete implementations. But still, it gets you very close to where you need to be.
I always use Dreamweaver's site / directory search function. It will scan through all the files in the Core folder and tell you where the function is from. In your case, I would search for "renderTotals". You need to enable PHTML editing in Dreamweaver.
Most IDE's will allow this kind of search option. In Aptana you can Ctrl + Click on the function to open the file it is coming from. Magento takes ages to index itself on Aptana, due to its sheer size.