I have a views page which tracks posts created by users. Its having a field(comment_count) to show no of comments in a node. the field is working fine except its showing blank spaces in fields with no comments.
I am using the template file views-view-field--tracker--page--comment-count.tpl.php and copying the line <?php print $output;?> as suggested by views. but i have no idea how to modify the template output to ... replace the empty spaces with text such as 'no comments' or something similar. I would really appreciate if anyone can help me on this.
There are more templates involved in View processing. Go to admin/build/views/, edit your view and see Theme: Information. There you'll get currently used templates, their brief descriptions and default code.
As for field template, there are some variables available:
$view: The view object
$field: The field handler object that can process the input
$row: The raw SQL result that can be used
$output: The processed output that will normally be used.
Related
Is there a way to publish the amount of views/edits of a page in/on the page itself in xWiki?
I've used parts of this article to create an accessible form to see usages of different spaces. But I would also like to publish the views/edits on the pages itself.
Thanks in advance!
Richard
I would suggest you use an UIExtension point (see https://extensions.xwiki.org/xwiki/bin/view/Extension/UIExtension%20Module and the tutorial https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Tutorials/UIXTutorial/) from the list of available ones (https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/ExtensionPoint/) to add the extra information to be displayed on each page.
I guess the most suitable UIXP would be the Content Footer one (https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/ExtensionPoint/ContentFooterUIX/).
Inside the UIX you add, you can do a simple query to fetch the view/edit values from the statistics module (either with the API, if it exists) or with a HQL query, like in the example you've mentioned.
tl;dr
Within OrchardCMS, is there any way to automatically migrate the contents of a BodyPart into a LayoutPart? And if so, how?
Detail
I am upgrading an old Orchard instance (v1.8.x) that used the old BodyPart. The goal is to update OrchardCMS to the current release, and with it, migrate to the new Layout system added in v1.9. Enabling the Layout module will add the LayoutPart to content items such as Page, but the two parts both exist on the Content Definition, and moving content from the BodyPart to the LayoutPart seems to be a manual process. Is there any way to automatically migrate content from the BodyPart to the LayoutPart, perhaps even if it was nested within a single Grid->Row->Column(12)->HTML block? And if so, how?
I think you should be able to do this with a little bit of playing around and a little bit of find & replace in your code editor. I would take an empty new site and export two pages, one with content in the BodyPart and one with content in the LayoutPart they way you want it to look. You should be able to see how they are different, I haven't looked at how they export recently, but I think the body part html is contained in a pretty simple xml tag while the layout part includes some code to designate all the elements, with the html contained inside.
Next step is to export all the content from your site (using import/export) and use a good text editor to convert all the body parts into layout parts using find & Replace.
Finally, import the edited file back into the site.
I haven't tried any of this so obviously have a database backup handy and test this out in a dev environment first. Also, I'm guessing that if you follow the directions above you will end up with duplicate content in the body and layout, so you probably want to make sure your import has an empty body tag for each page.
Please excuse if there is a better way to do this, I'm not too familiar with SharePoint web parts, I'm only just now getting into creating them.
What I want to do is have a web part that I can drop into a page, give it a parameter, and then the web part does it's API calls with said parameter, does some XSL transformation, and spits out the HTML that I want to display on the page. In my mind it seems like a simple little web part to write, I just want to make sure this is the best way to go about it and not be duplicating something that could already be existing.
I've gone through this creating a basic web part walkthrough, and I figure I can use the web part property to get the parameter from the user. How would I get it to output HTML though? I changed the "Hello, world!" text to output some HTML and it seemed to have gotten stripped out?
Thanks a ton, and sorry if anything seems noob-ish!
From what I see, there are two main parts to what you want to do.
Get your parameter into your query
Format the results with some HTML
Reuse it later
There are a lot of ways to do this, but I'm going to outline what I believe to be the fastest and most simple.
Getting your parameter into your query
In SharePoint 2010, SharePoint designer has some great options for this.
So step 1 is to open the webpage in SharePoint Designer.
Click the Insert tab and click the Data View dropdown and select the list you want to get data from.
Now click on the Options tab and click on Parameters
The dialog shows you some of the options for pulling info into your query.
A query string parameter is easy to use. And the server variables are also really handy.
For our example, we'll pick query string and set the default value to 1 (which will be the ID of an item we want to be retrieved). Since we've set this as the default, even if the query string is blank we'll still get our default in our parameter.
Then click on Filter.
We set our Field Criteria to use the parameter we just made.
Now you can save the page in SharePoint Designer and test your results. Pretty fast.
Format the results with some HTML
In SharePoint, XSLT is the best way to put your own HTML around some data you've retrieved from SharePoint.
Also, for getting a parameter into your query, we can add that with a parameter binding:
If you're new to XSL, here's the best xsl tool:
http://spexp-blog-files.s3.amazonaws.com/blog/files/spe-magic-data-view-builder.xsl
To use the magic dataview builder, save this file to documetn library in your farm.
If you’d like to centralize your XSL template for greater reuse (highly recommended), you can put the individual XSL files into a central location for storage. In a WSS or SharePoint Foundation environment, I’d recommend using a Document Library in the root site of your Site Collection. In a MOSS or SharePoint Server 2010 environment, I’d recommend placing the XSL files in the /Style Library/XSL Style Sheets location, as this is where SharePoint stores its XSL by default.
Then paste the url to the file into the XSL Link to replace main.xsl and change Default to FALSE. This property is located near the end of the <XmlDefinition> tag as you view the webpart in Designer.
... <XslLink Default="TRUE">main.xsl</XslLink><Toolbar Type="Standard"/></View></XmlDefinition>
From there, you can save the page and the XSL wizard from magic data view builder will walk you through creating your own xsl to output your html.
Reusing Your Webpart
To reuse it, click save "To Site Gallery" while your cursor is on the wepart in SharePoint Designer. This will save the webpart into the gallery under the "Custom" group. From there, you an insert your webpart into other pages just like the out of the box webparts.
I think we need more information about what you are trying to get the web part to do. If you use a SharePoint Data View web part, you can point it at a data source, write some XSL to transform the data to render the way you want it will output the HTML to the page. For example, let's say I have a SharePoint list of training classes. I could create a data view web part that takes a query string or other input parameter as its filter, and filter the list of classes to show me just the one that matches the ID of my query string or input param. Then I could format my XSL to output details about the class rendered in whatever fancy HTML I want.
Does that help?
"I changed the "Hello, world!" text to output some HTML and it seemed
to have gotten stripped out?"
Please be aware that in your sample, it uses a LiteralControl() which by default HTML Escapes any text. So if you need HTML outputed via the LiteralControl.Text element, you will need to set the Mode to "Passthrough".
protected override void CreateChildControls()
{
base.CreateChildControls();
LiteralControl message = new LiteralControl();
// !! add this !!
message.Mode = LiteralMode.PassThrough;
message.Text = DisplayMessage; // <-- containing HTML
Controls.Add(message);
}
I have a question regarding Drupal 7 and the Views API.
I'm writing a module that replaces specific text in views. Essentially what I'm trying to do is scan text in a view (or page for that matter). Let's say the view has [special button] will be replaced with
l(t('button'),'mypage',array('query',array('page'=>$node->nid)));
Or whatever. Please understand this is pseudo code.
I've took a look at hook_view(), hook_node_view() (http://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_view/7) and neither of them seem to work for me.
I've also looked at http://drupal.org/node/1510828 but that didn't seem to help me out.
Have you tried selecting 'rewrite the output of this field' on the field/s ?
Or alternatively Views PHP should be able to do what you want.
I wanted to write a hook which will place a new field in new document type along with present ones(textbox, selectbox etc.)."I need That new field which works like dropdown box under Metadatasets as screen shot shows .and also i need to get values from database whenever i select that field in the available fields if we choose "select" it show option1 ,option2 ,option3 .."
Can anyone know which js and jsp files should I edit.? Please help
https://www.liferay.com/documentation/liferay-portal/6.1/user-guide/-/ai/lp-6-1-ugen04-document-types-and-metadata-sets-0
i was unable to upload image,Can u plz see the above link.in this page figure 4.6 is the image.
Since Document Types are part of Document library so you can check-out: \portal-web\docroot\html\portlet\document_library\edit_file_entry_type.jsp. and other related pages which might be accessed from this page.
Hope this is what you want, again I would suggest to please pay heed to my comments to your question.