Drupal 7 Template Suggestions not working - drupal-7

If I create a region in the info file like:
regions[footer_panel] = Footer panel
then render this in the page template (page.tpl.php):
print render($page['footer_panel']);
then try and create an overide template to work with (as described in documentation):
block--footer_panel.tpl.php
finally print some static text in that file, Im not getting any results. Please could someone advise?
Caches have been flushed and block.tpl is in the templates folder.

Try adding the generic block.tpl.php to the theme as well. Sometimes it won't pick up the block template suggestions if that file isn't present first. Be sure to clear the cache again.
I'm also assuming that you have a block inserted into that region. If you do not have a block designated to show in that region creating a template file will do nothing. You need to create a block and then create the template file based on that blocks name/ID not the region name.

Related

How to render content outside of drupal instance

i created one website using drupal. In Drupal i crated content pages in that instance using wisywig editor. now my intention is using this content block outside of drupal. can you anyone please help me how to use this content block outside of drupal (with code or something else).
i mean how to render content outside of drupal instance
Rendering blocks and nodes is straight-forward.
Before you can do either you must initiate the drupal core:
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
Using getcwd() assumes you are placing the script in drupal's root.
To display blocks, use block_load():
$blocks[] = block_load('block',$delta); //first block to display
$blocks[] = block_load('block',$delta2); //second block to display
print drupal_render(_block_get_renderable_array(_block_render_blocks($blocks)));
For nodes, there are several approaches. node_view(node_load()) seems to be the cleanest:
print drupal_render(node_view(node_load($nodeId)));

HelperProvider always open the index file

I want to build a context sensitive help for a winforms application, to do this I use a class with a reference to the HelperProvider component, HelpNamespace is set to the index html file and when a form is loaded I register each control in the form to the helperprovider with a topic that I get from a config file :
helpProvider.SetShowHelp(control, true);
helpProvider.SetHelpNavigator(control, helpNavigator);
helpProvider.SetHelpKeyword(control, helpKeyword);
when debugging I am sure that some controls are configured with some topics different from index file but when running and pressing F1 its always the index file (HelpNamespace) that is opened. When using a HelperProvider instance for each control and no single instance for all controls, that works fine!
Why I can't use a single instance of helperProvider for all controls?
You need SetHelpKeyword for each control. A HelpNavigator.TopicId may be useful for a CHM with topic ID's inside.
I'm missing ".Topic" in your code sample above. Try the code below or download a working example from:
http://www.help-info.de/files_download/CSharp2008_CHM.zip
// set F1 help topic for controls on this form
helpProvider1.SetHelpNavigator(this.btnStart, HelpNavigator.Topic);
helpProvider1.SetHelpKeyword(this.btnStart, #"/Garden/flowers.htm");
helpProvider1.SetHelpNavigator(this.btnExit, HelpNavigator.Topic);
helpProvider1.SetHelpKeyword(this.btnExit, #"/Garden/tree.htm");
helpProvider1.SetHelpNavigator(this.chkShowHelpWithNavigationPane, HelpNavigator.Topic);
helpProvider1.SetHelpKeyword(this.chkShowHelpWithNavigationPane, #"/HTMLHelp_Examples/jump_to_anchor.htm#AnchorSample");

How to alter the prefixes EPiServer is adding to src attributes in html

I have a fragment of html which is contained in a property of a templated EPiServer page, within that html there is an img tag which has a relative url in it.
When the page is viewed, I can see the src attribute of the tag has been altered to have the prefix /ProjectName/Templates/Pages/.
I understand that this is being done by HtmlRewriteToExternal so that image files that are stored alongside the aspx template (which does indeed live in Templates\Pages) are located correctly, however the image which is intended to be part of the html fragment is in my case actually stored under PageFiles/nnn/ (where nnn is actually the parent page's PageFolderID), and I need to somehow make the altered html reflect that.
I've created a class that inherits from FriendlyUrlRewriteProvider and registered my class. I can debug the application, and watch the requests go through the overridden methods, but I still can't see where the prefix is being added or get any idea how to change it. I can alter the src tag to a different relative path in my class, but the prefix is still being added.
I've read everything I can find on the EPiServer url rewriting, but can't find anything that hints as to where this prefix is being added or how to stop that or change it.
Things I've read:
http://blogs.interakting.co.uk/post/File-Extensions-and-URL-Rewriting-in-EPiServer.aspx
http://blog.fredrikhaglund.se/blog/2008/05/07/disable-episerver-urlrewriter-interference/ (this may contain the answer I'm looking for)
http://labs.kaliko.com/2010/11/prevent-episerver-urlrewrite.html
http://sourcecodebean.com/archives/episerver-friendly-urls-for-paginated-pages-and-why-the-asplinkbutton-must-die/510
http://tedgustaf.com/en/blog/2008/7/create-a-custom-url-rewrite-provider-for-episerver/
http://tedgustaf.com/en/blog/2011/4/publishing-plain-html-pages-in-episerver/
http://sdk.episerver.com/library/cms5/Developers%20Guide/Friendly%20URL.htm
http://sdk.episerver.com/library/cms6.1/html/T_EPiServer_Web_UrlRewriteModule.htm
http://labs.episerver.com/en/Blogs/Ruwen/Dates/111218/112064/112154/
http://world.episerver.com/Blogs/Magnus-Strale/Dates/2011/3/Do-we-really-need-yet-another-HTML-parser/
http://world.episerver.com/Blogs/Yugeen-Klimenko/Dates/2011/6/How-EPiServer-URL-Rewriting-works/
http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=46869
I'm open to completely different solutions for what I'm actually trying to achieve, which is as follows:
I have multiple independent sets of static html files and related image / css / js files, which I'm trying to store / publish with EPiServer. The structure of each set looks something like
setfolder/
htmlfileA.html
htmlfileB.html
css/
styles.css
images/
piccy1.png
piccy2.png
js/
magic.js
I've figured that I should create an EPiServer page for the set, and then child pages for each html file, storing the html from the files in a property of the child pages. Currently I'm storing the related static files in the PageFiles of the relevant setfolder page, as that seems to be the most logically consistent place to put them.
It's hard to give the best solution without seeing it all infront of you. But one easy way is to alter the HTML-code when you print the property to the page.
Like <%= ChangeRelativeLinks(CurrentPage["HtmlCode"] as string) %>
And in the ChangeRelativeLinks(string htmlCode) you do a regexp or similar that changes relative links and images to the pagedir as an absolute path.
If you are storing the images in PageFiles which is a Virtual Path Provider you should be able to get the url to your file simply by using the API. On the PageData class (ie CurrentPage in your template) you have a method called GetPageDirectory() which gets the page folder.
You can read more about VPP concepts here:
http://sdk.episerver.com/library/cms6.1/Developers%20Guide/Core%20Features/File%20System/File%20System%20and%20VPPs.htm
No need for a url rewrite provider for this I think.

Drupal 7 header

This may sound like a very obvious question for drupalistas, but for the life of me, I can't figure out where the header element is so I can rearrange it to put the search above the main menu. I am using a subtheme off of a very stark theme called framework.
I see this line:
I want to know where the code resides so I can set the blocks to print the search block first and the main menu second.
You can move your blocks around in the page.tpl.php template file.
If you've not done so already copy modules/system/page.tpl.php to YOUR_THEME/templates/page.tpl.php and clear your cache out.
Open the page.tpl.php file and you'll see where your blocks are printed out.
e.g. <?php print render($page['header']); ?>
Will print your header block out.
From there you can put blocks in any order you want.
To reorder in a block, go to admin -> blocks and use the arrows on the left of each block to drag them into the order you want them to be rendered. Remember to save your order and you should be set.

Drupal Attachments (FileField) file path

What function in Drupal gets file attachment path?
Edit: the attachments provided by Upload module in system section. But since you mentioned there may be another way around it. Maybe I could achieve may goals using FileField module so if you could tell me how to get a direct link of a file uploaded by FileField module that may also be very helpful.
Edit 2:
Ok I will start from my main and final objective:
It is to get an image linking to a file which visibility I could be managed using CCK module.
I am doing this step by step. So now I have written a code which generates the needed image and I have added that image to one of content types teaser. I found a way to warp my image in a tag and I had dug up simple attachments url. So my next step is to advance from simple upload attachment to the one added by FileFields and from odd looking HTML pace in all PHP document into beautifully managed CCK field.
How to fetch file path of a file uploaded FileFields?
Some plain and at the same time rich tutorials for making custom fields for CCK module.
Assuming you know how to get the $node object for a node containing a file attachment, this is super easy:
Upload (core)
$file = upload_load($node);
echo $file[1]->filepath;
Where 1 is the index of the file. Upload can let you upload more than one file, so file 2 would have an index of 2 and so on. If there's only one file, it'll always be 1.
More info: upload_load() API reference.
FileField
echo $node->field_fieldname[0]['filepath'];
Where field_filename is the short name you've used for the field, and 0 is the index of the field. CCK fields let you have multiple values in one field, so 0 would be the first, 1 would be the second, etc. If you only have one value, it'll always be 0.
Note: if you want to get the rendered output of the FileField using its formatters, you can just use $field_fieldname in your node template, or if you want to store the rendered output, you can use:
echo content_format('field_fieldname', $node->field_fieldname[0]);
More info: content_format() API reference.
Upload is a sad little module, and has been completely replaced with a core implementation of FileField in Drupal 7. If you have the option to use FileField, you should.
Don't direct links of file attachments appear below the uploaded file for the core Upload module?
Since you are trying to use images, you should use http://drupal.org/project/imagefield CCK module in order to add images to specified content type. After that using the Display fields tab in Content type configuration you can specify how image would be presented (as a link, image, image with link to node...) both in teaser and body view.

Resources