I'm trying to specify a relative path for the source of a droplink/dropsource.
Specifically, I have a folder structure where I have an Authors folder under a certain branch. On the same level of that Authors folder, there can be items or folders with items that will have a droplist that could point to that Authors folder for it's source. The issue though is that this is going to be repeated for multiple clients, so I don't want to have to manually specify the source directory in each case but rather just have a relative source that says basically find the closest Authors folder to me (sibling, aunt/uncle, great aunt/uncle, etc.). Any way to do this? Do I need to use Sitecore query syntax for this?
Yes this is possible with a query.
In the Source field of your droplink Template field set something like:
query:./ancestor-or-self::*[##templatename='yoursitesite']/home/*
or
query:../*
Depend on your exact structure, or template names.
See:
For SXA, see use-a-query-to-determine-the-data-source-context
More explanation sitecore-field-source-as-xpath-query-or-fastquery-cheat-sheet/
Related
I want to extract dates from the suffixes of files in a particular folder. The contents of such a folder look something like:
Packed_Folder_1_2016.06.10
Packed_Folder_1_2016.08.06
Packed_Folder_1_2015.09.03
packed_Folder_1_2015.01.08
... (so on and so forth, always in the same path just different suffixes)
There is no pattern to the dates. I need to make a VS form (2013) to read the name of the files and store the date differences.
Notice how the filenames always follow a pattern? It's always Packed_Folder_1_####.##.##, where the last part is a date.
So what you want to do is list the file names in the folder, and try to find a file that matches the pattern. You could use a regular expression to match the filename (it would be something like R"(Packed_Folder_1_\d{4}\.\d{2}\.\d{2})").
You are talking about Forms, so I am assuming you are able to use Visual C++. If that is the case, you can check FileSystemWatcher Class.
You instantiated it with a given path ( file or directory ), and it will trigger events based on some changes on the target (simple change, creation, rename - you can select which one). You could then update your reference, in case its change suits your needs.
Normally when we double click on a themepack file it is applied on our system and a corresponding folder with the same name as the themepack is saved in
C:\Users\<username>\AppData\Local\Microsoft\Windows\Themes
Now if I have multiple themepack files and I have applied each of them at least once, then all the themepacks will have a corresponding folder in the Themes folder. Now I want to know which particular theme is applied on my machine, programmatically.
(When we use a themepack file Custom.theme file is not updated)
I'm pretty sure there's no API that can retrieve that information. Which makes sense, it isn't really relevant. An application never needs to know the name of the theme pack that the user selected.
What you can get using an API, and what is useful, is the name and properties of the theme that the user has enabled. For example, calling the GetCurrentThemeName() function and/or the GetThemeDocumentationProperty() function.aspx) with SZ_THDOCPROP_DISPLAYNAME will tell you whether the user has enabled the Aero theme or not. Or if they're using a custom theme that is not Aero. Just to be sure, though, I tested it, and neither of those functions returns the name of my currently selected theme pack.
However, you can read the registry to obtain the information you desire. Find it in the following location:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\CurrentTheme
That value will contain a string corresponding to the full path to the currently selected theme pack, e.g.:
C:\Users\billg\AppData\Local\Microsoft\Windows\Themes\Pink Polka Dots.theme
If you want, you can strip out the path spec and extension, using just the file name as the name of the theme pack, e.g. Pink Polka Dots.
But that isn't a complete solution because it doesn't take localization into account. Especially with system-provided theme packs, the file name is going to be in English, but the name of the theme pack is going to be localized in the UI. The user sees something different when they pick themes.
I want to rename NOT inner folder(rhuk_milkyway оr others). But exactly folder "templates".
I think it one of the ways to protect site from regular virus attaks.
I changed:
1). folder name
2). paths in file index.php in that folder
What else must I do?
I don't think that renaming templates folder would do any good. You can still see path of template css, js and images in html source.
Lets say you rename your templates folder to secret_folder, but when viewing html source you will see /secret_folder/rhuk_milkyway/css/style.css instead of /templates/rhuk_milkyway/css/style.css.
If you're afraid of regular virus attacks - get right folder permissions, and it should do the trick.
I am using this code for display my page in page content in MURA 6.1
<div>[mura]$.dspInclude('display_objects/custom/main.cfm')[/mura]</div>
But it gives me the error below:
Note: If you wish to use an absolute template path (for example,
template="/mypath/index.cfm") with CFINCLUDE, you must create a
mapping for the path using the ColdFusion Administrator. Or, you can
use per-application settings to specify mappings specific to this
application by specifying a mappings struct to THIS.mappings in
Application.cfc. Using relative paths (for example,
template="index.cfm" or template="../index.cfm") does not require the
creation of any special mappings. It is therefore recommended that you
use relative paths with CFINCLUDE whenever possible. Could not find
the included template
/muraWRM/default/includes/display_objects/custom/main.cfm.
The physical path is
[siteid]/default\includes\themes\rescue\display_objects
Thanks in advance
This should work
<div>[mura]$.dspInclude('themes/rescue/display_objects/custom/main.cfm')[/mura]</div>
Your include is being called from the includes folder, so you need to include the themes folder and the rescue folder to get to the right path.
For consistency across themes, you might want to use Mura's setting for the theme name, but I would have to look that up.
If you are ok hard coding it, this should work just fine.
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.