How can i add an additional class the Drupal’s search form’s submit button? - theming

I’m trying to add an additional class to the Search form’s submit button. I’m attempting to display a icon font instead of the word Search. The mark-up for this button w/ my added class would be this
<input type=“submit” id=“someid” value=“” class=“form-submit flaticon-magnifier12” />
i’ve successfully removed the word search from the value field by modifying the search.module file.
i looked for a ref. to the class ‘form-submit’ but it is not in that file.
i also tried the following in the template.php file.
function mytheme_form_alter(&$form, &$form_state, $form_id){
if($form_id == 'search_block_form'){
$form[actions][submit][‘#class’] = ‘form-submit flaticon- magnifier12’;
}
}
but that didn’t work!, any help in this matter would be greatly appreciated.

You should use:
$form['actions']['submit']['#attributes']['class'][] = "form-submit flaticon";

Related

how to enter a carriage return in a Link label field

I've got several Link fields on an xPage. The labels of these link fields are retrieved from a Notes document. I want to insert a carriage return into the text so the text when displayed on the web page is split into 2 lines. Entering
<br/>
used to work for label fields so I tried that but it doesn't work anymore. Maybe some xpage update changed that functionality. Anyone know another way of doing this?
thanks clem
You need to set the escape property to false in order to allow HTML. Here's an example:
<xp:link escape="false" id="test" value="http://example.com">
<xp:this.text><![CDATA[#{javascript:"Test 1<br/>Test 2"}]]></xp:this.text>
</xp:link>

Issue while saving the dynamic field values in the preferences

I have already posted one question on the same issue. But I'm not able to solve my issue and not able to move forward in my task.
I have created a editable portlet where in the configuration page I am showing he dynamic questions which are fetching form the database. So for the same reason I am iterating my array list and creating the input fields dynamically as follows,
Iterator<String> itr = al.iterator();
while(itr.hasNext())
{
String columnVal = itr.next();
columnVal = columnVal.trim().toLowerCase();
%>
<aui:input name="<%=columnVal%>" type="checkbox" />
<%
}
With the above code the fields are creating dynamically with proper labels and seems to be fine.
When I try to save these dynamic field values in the preference I changed my input statement syntax to the proper way by adding the prefix as "preferences--" and suffix as "--" as shown below,
<aui:input name="preferences--<%=columnVal%>--" type="checkbox" />
I don't know what syntax is wrong in the above statement. But I am not able to see the label names in UI. instead of showing the proper label names for all labels it is showing <%=columnVal%> on UI.
I am using default configuration action class in my liferay-portlet.xml as mentioned below,
<configuration-action-class>com.liferay.portal.kernel.portlet.DefaultConfigurationAction</configuration-action-class>
Can any one please correct my syntax and help me to save my dynamic field values in the preferences.
From reference link's comment section:
According to JSP 2.1 Specification multiple expressions and mixing of
expressions and string constants are not permitted.
So you have to use below code in your case:
<aui:input name='<%="preferences--"+columnVal+"--"%>' type="checkbox" />

Wordpress: Display content from a Custom Post Type within a regular Post

I feel like there is a really simple solution to this problem. However, after trying to solve it for about 3 hours unsuccessfully, I humbly come to you.
The Basics:
A custom post type, " band ", has been created, and has several
custom fields (which were created through the Advanced Custom
Fields
plugin.)
The Question:
How would I get and display the contents (specifically custom field data) of a specific band entry (using its ID or title or slug) inside of a regular post? (see diagram below)
(source: thisnewband.com)
.
Methods to Trigger the Display of the Custom Post Type:
We have to provide the ID/title/slug so that it knows what band post's content to display
Shortcode (such as [band id="21"] ) (added inside post content)
Custom Field (custom field name band-id where you can input the ID of the band)
What I've Tried and Why It Didn't Work:
Shortcode
`[band id="21"] inserted in post editor field
Used WP_Query to query post with type=band and ID="21".
Code located in functions.php
Result: It would echo static text but would not display any post-specific content (Band Name, etc.). Also would not pull post-specific custom field data.
(also tried query_post with no luck)
Custom Field
Entered ID (21) into custom field on post editor page.
Coded it directly into the post template:
Used WP_Query and had the ID in the array pull from the custom field.
Result: Nothing good happened.
Where I Keep Running Into Trouble:
It's hard to pull the custom field data from the custom post type while inside an actual post
The Optimal Solution:
Whether it's by using a shortcode, custom field, or even a new widget, it would be easiest if one could:
Create a PHP template with the code for just how the single Band content is supposed to display. (Including the loop). Example name: band-block.php
Use get_template_part('band-block'); to echo this code (either in Post Template or Shortcode via functions.php)
Thanks for your help! Let me know if you'd like to see any of my code.
I knew you have found a solution for your problem, but for others i will give them an other solution:
You can query by ID, no problem. Look at these: http://www.advancedcustomfields.com/resources/field-types/relationship/
But you have to check in the custom field "return format" the box "Post IDs". Then it works perfectly well.
Sorry for my bad english ;)
Cheers
With some amazing help from Hobo, I was able to come up with a solution!
The main problem was with trying to query by 'ID'. No matter what we tried, it just never worked well. (It could be the way that the Advanced Custom Fields stored the ID field contents.)
What did work:
Created a custom field for the post page in which to put the Band (custom post type) post name/slug into. (Custom field was named post-band-name and created with the Advanced Custom Fields plugin.)
Placed the query code in the Post Template. (See code below)
Done.
The Solution Code
Add this loop after the normal loop...
<?php /* Display all the author's posts from the custom post type ('band') */ ?>
<?php
$authorid = get_the_author_meta( ID, $userID );
$args4=array('author'=>$authorid,'post_type'=>'band', 'numberposts'=> -1);
$cquery4=new WP_Query($args4);
if($cquery4->have_posts()):
while($cquery4->have_posts()):
$cquery4->the_post();
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<p><?php the_title();?></p>
</a>
<?
endwhile;
wp_reset_postdata();
endif;
?>

Building a list of downloadable items in Orchard 1.6

I'm fairly new to Orchard and I'm wondering about the "best" way of building a basic list of documents with a download link?
Say the scenario is this, I want to make a list of newsletters, the news letter are in PDF format and the users should be able to download then straight from the list view.
An admin, should easily be able to add a new newsletter and it should turn up in the list.
My current train of thought is to, all through the dashboard,
create a content type "Newsletter" with a title field and a Media picker field, using the media picker field to upload the PDF file.
Then create a query, with the filter on Content type "Newsletter"
Create a projection pointing to the query
However, this only gives me a list of content items, showing their title as links back to the actual content item.
I've tried adding a layout to the query and set it to display properties instead of content. By doing that I can get a list where I can control the "output" a bit more. And I've gotten it to list the title and by doing a Rewrite and putting in the MediaPicker.Url, it also displays the URL in the list. This is all good but here I get stuck..
As the MediaPicker.URL outputs the url in the format like ~/media/default/xyz/filename.pdf, I cant just put it into a a href, it doesn't give a correct download link to the file.
Soo, question is, am I thinking and doing this totally the wrong way or am I missing something obvious? All ideas and suggestions and more then welcome.
Use or adapt the following template override in your theme:
#{
var url = Model.ContentField.Url;
}
#if(Model.ContentField.Url != null) {
if (url.StartsWith("~/")) {
url = Href(url);
}
<div class="media-picker-field attachment-pdf">
<span>download</span>
</div>
}
Modify the text as needed. This template was a Fields.MediaPicker-PDF.cshtml that was used for a media picker field named PDF.

SharePoint - Custom Dataview - Link Rendering Issues

I have a custom SharePoint page with several dataviews. The dataviews essentially filter documents matching a certain criteria from a document library and display a link to the document along with some other meta data.
The problem I have is that when a document has a single quote in it's title, the character is being rendered as ' and invalidating the link. This is the code within my custom page that is displaying the invalid link.
<A onfocus="OnLink(this)" HREF="{#FileRef}" onclick="return DispEx(this,event,'','','','','{ddwrt:ListProperty("DefaultItemOpen")}','{ddwrt:MapToControl("", string())}','{#HTML_x0020_File_x0020_Type}','','{ddwrt:GetUserID('CheckoutUser')}','{$Userid}','{ddwrt:ListProperty("ForceCheckout")}','{$FieldIDA5KNTB}','{ddwrt:CurrentRights()}')"><xsl:value-of select="ddwrt:UrlBaseName(string(#LinkFilename))" /></A>
Does anyone have any thoughts on how I can ensure the #FileRef variable is encoded correctly before being rendered?
Many thanks in advance :)
you need to use the ServerURL or EncodedAbsUrl properties, this guys written it out already:
Itay Shakury's blog

Resources