I have downloaded a template with a module called Publications. When the News Page is loaded it calls this .tpl file:
{title}{$category.title}{/title}
<div class="newsPage">
<h1>Latest News</h1>
{foreach from=$articles item=entry name=articles}
{if $smarty.foreach.articles.first}<dl><br />{/if}
<dt><a href="{$GLOBALS.site_url}/publications/{$category.id}/{$entry.id}/{$entry.title|replace:' ':'-'|escape:"urlpathinfo"}.html" class="title"></dt>
<dd>{$entry.description}</dd>
{if $smarty.foreach.articles.last}</dl></a>{/if}
{foreachelse}
[[There are no articles available at this time]]
{/foreach}
</div>
And there's the problem. If there are 1000 articles, all of them will be loaded and no pages will be created.
I'm trying to create a "show more" button with only the latest 4 articles displayed at first and then when the "show more" button is clicked, the next 4 articles will be displayed, and so on...
Is that possible? Can anyone help me with new ways to create a dynamic news section with this?
i still didnt install my editor, but you can give a div or any thing some property, which make that object hidden, i'm not sure if it was block, or hidden it self,
then you can also give it an id, and refer to it with java script, and as you already know a query language like jQuery, you can do it even simpler to refer to the div element, and change its property, (i didnt worked with jQuery), if it's about to be as a toltip, you can use your parent div/ image/ button/ any thing:
[style]:hover{display:block;}
for styles which normaly are:
[style]{display:none;}
or instead of display, u can use
[style]:hover{visibility:visible;}
for stle which are like this:
[style]{visibility:hidden;}
this is a ways which most of sites menus take advantage of
Solved. Changed the <dl> <dt> <dd> to <ul> <li> and then:
var vis = 5;
$('.news li').slice(vis).hide();
var $more = $('Mais')
$more.click(function(){
$('.news li:hidden').slice(0,vis).show();
if($('.news li:hidden').length == 0)
$more.hide();
});
$('.newsPage ul').after($more);
Related
I am writing a selenium script that automates a web-page. I need to click on a button which is defined within a list.
This is the image of my web UI - New Account is the button I am referring to
This is my XML code :
<div id="00B4E000000LQ2C_topNav" class="topNav primaryPalette">
<div id="00B4E000000LQ2C_subNav" class="subNav">
<div class="linkBar brandSecondaryBrd">
<div id="00B4E000000LQ2C_listButtons" class="listButtons">
<ul class="piped">
<li>
<input class="btn" type="button" title="New Account" onclick="navigateToUrl('/setup/ui/recordtypeselect.jsp?ent=Account&ekp=001&retURL=%2F001%3Ffcf%3D00B4E000000LQ2C%26isdtp%3Dnv%26nonce%3Df8007ad94993912b7ff4149193a6096ccfed4ebb1454e0b9b310ad14b61de71d%26sfdcIFrameOrigin%3Dhttps%253A%252F%252Fcs83.salesforce.com&save_new_url=%2F001%2Fe%3FretURL%3D%252F001%253Ffcf%253D00B4E000000LQ2C%2526isdtp%253Dnv%2526nonce%253Df8007ad94993912b7ff4149193a6096ccfed4ebb1454e0b9b310ad14b61de71d%2526sfdcIFrameOrigin%253Dhttps%25253A%25252F%25252Fcs83.salesforce.com&isdtp=vw','LIST_VIEW','new');" name="new" value="New Account"/>
</li>
<li class="lastItem">
</ul>
I used:
driver.findElement(By.xpath(".//*[#id='00B4E000000LQ2C_listButtons']/ul/li[1]/input")).click();
(Xpath was given by the firebug) but it gives me an error stating
unable to locate elements
Please help me script / locate this button.
You don't have to use XPaths generated by the Firebug and check the element's parents along the way. We can do better, you can write a more reliable and a simpler way to locate the element:
driver.findElement(By.name("new"));
or:
driver.findElement(By.cssSelector("input[name=new]"));
or:
driver.findElement(By.cssSelector("input[value='New Account']"));
Note that the XPath expression you have looks valid. You may be experiencing a timing issue and would need to wait for the element presence, visibility or clickability, see: How to wait until an element is present in Selenium?.
And, if the button is inside the iframe, you need to switch to its context and only then search the button:
driver.switchTo().frame("ext-comp-1005");
Hi please try like below
// first way
driver.findElement(By.xpath("//*[#name='new']")).click();
// second way
driver.findElement(By.xpath("//*[#class='btn']")).click();
// basically you can use various attributes of input tag with button inside the xpath to click
Update working with i frame
// A short way to identify how many iframe's are present on a web page
List<WebElement> numberOfFrames= driver.findElements(By.tagName("iframe"));
System.out.println("Total Number of iframes present are : " +numberOfFrames.size());
for(int i=0;i<numberOfFrames.size();i++){
// here u can identify iframes with any of its attribute vale say name,title or which is most suitable.
System.out.println("Name of the i-frames : " + numberOfFrames.get(i).getAttribute("name"));
}
// Back to your question - button lies inside iframe hence
// key here is before clicking you have to switch to the frame first
driver.switchTo().frame(driver.findElement(By.name("frame name")));
hope this helps you
This seems to be a very simple concept, but I am unable to resolve. What I'm trying to do is, render/display a Standard value of a template, to the page.
Created the items & templates using Rocks. Here is the structure.
1. Sublayout - footer.ascx
<div class="content">
<h1>This is a title.</h1>
<p>All the content goes here</p>
<sc:placeholder runat="server" Key="footercontent" />
</div>
2. Sublayout - StickyNav.ascx
<a class="btn" href="#">
<sc:Text Field="Sticky Nav Title" runat="server" />
</a>
3. Template - Sticky Nav
The first pic is of the template & the second one shows the assigned default value in _Standard Values.
Then, in Sitecore Explorer,
right clicked on (Sticky Nav - _Standard Values) > Tasks > Design Layout on Standard Values.
Now, there is a content item "index" under /sitecore/content/. It has these layouts declared:
When I right click on Index > Tools > Browse > Preview, the index page does open and the footer content is also displayed.
But, I am unable to see the text 'Go To Top', that was set as a Standard value (Image 2). It is empty.
What am i missing here.
There could be a few factors blocking the content being showed. For the front end the best bet is to rule out things like publishing - i.e. make sure that the template, fields, standard values, and the content items are all published correctly. If you are in preview this is probably of less relevance but worth noting when you deploy
When the sc:Text control renders is will be running the renderField pipeline. At the point that interacts it will be talking to Sitecore via the api.
To check things via the code behind for your control (assuming it's an ascx due to the runat="server" tag). Check:
Field field = Sitecore.Context.Item.Fields["Sticky Nav Title"];
if (field != null)
{
string value = field.Value;
}
And debug through to check the field actually has the value you require.
In the cms, when you view the page of interest does the 'Sticky Nav Title' field appear to have a value, and be the value you are interested in?
I realized the initial thought itself was a mistake. There HAS to be an item if it's value has to be displayed on page.
So, I created a new item under /sitecore/content/Sticky Nav Button using the template Sticky Nav.
And in StickyNav.ascx, updated the control as:
<sc:Text Field="Sticky Nav Title" runat="server" DataSource = "/sitecore/content/Sticky Nav Button"/>
Hope this helps beginners like me.
I'd like to open TinyMCE in a modal dialog from inside the custom block I am building. I know how to implement a modal dialog but couldn't figure out a way to integrate TinyMCE inside the dialog.
What I am trying to achieve is when a text is clicked in the block add/edit popup, it should open up a dialog with TinyMCE to edit that clicked text. Anyone done this before?
This is what I am trying to achieve in add/edit forms:
$this->addHeaderItem(Loader::helper('html')->javascript('tiny_mce/tiny_mce.js'));
Loader::element('editor_init');
Loader::element('editor_config');
Loader::element('editor_controls');
<textarea name="field-name" class="text-area-value ccm-input-textarea">Some text here or empty....</textarea>
$bt = BlockType::getByHandle('myblock');
<a class="dialog-launch ccm-block-type-inner"
dialog-on-close="ccm_blockWindowAfterClose()" dialog-append-buttons="true"
dialog-modal="false" dialog-width="500"
dialog-height="500" dialog-title="<?php echo t('Add/Edit Text)?>"
href="<?php echo $th->getBlockTypeToolsURL($bt); ?>/tinymce_dialog.php?text=<?php echo $text-area-value; ?>">
Edit the above text in TinyMCE
</a>
In tinymce_dialog.php in tools folder:
<textarea name="textarea-name"
class="ccm-input-textarea advancedEditor ccm-advanced-editor">
<?php echo $_GET['text']; ?>
</textarea>
<div class="ccm-buttons dialog-buttons">
<a href="javascript:void(0)" onClick="ccm_blockWindowClose();"
class="ccm-button-left btn">Cancel</a>
Ok
</div>
But I am unable to pass the value of textarea into the modal dialog popup. I tried using href in the anchor tag to pass the value of textarea to a script that resides in the tools folder but that does not seem to work either.
Edit: I've also added buttons in tinymce_dialog.php (See the code above). Not sure if it's possible to pass those buttons through <a dialog-on-close="ccm_blockWindowAfterClose()" dialog-append-buttons="true".....> in the form.
Should work the same as anywhere else. First, include this line of code once in your dialog (you only need it once, regardless of how many TinyMCE's you have):
<?php Loader::element('editor_config'); ?>
Then, for each TinyMCE you want, use this:
<?php Loader::element('editor_controls'); ?>
<textarea name="your-field-name" class="ccm-advanced-editor"></textarea>
There's two ways to go about this:
As you describe in your question edits, where you load a tools file. There are a few points here:
URLs aren't great for passing text data, especially the kind of text that'd be edited in tinymce (long and formatted). With that being said, it should work. I don't see why the $_GET wouldnt' work. Make sure that the URL contains the text in the first place (you can see by looking at your developer console).
Better is to pass an ID (tinymce_dialog?id=[ID]). This is assuming that the text is saved in the DB, but it looks like you might be providing them an interface to basically "wysiwyg edit in a modal text that they're not-wyswiwyg editing already". I'm not sure if you've thought through how this will work, though. By default, they'll have to deal with a bunch of HTML tags ?
The alternative is to create the dialog out of an DOM element. Create a div hidden in the form, with CSS display: none;, save the text into it (if already initialized, tinymce has a .update() or something), and then show the hidden div (with Example 3 from http://www.concrete5.org/documentation/how-tos/developers/javascript-jquery-and-concrete5/). When they click (SAVE), you can then (presumably) copy the data out of tinymce and put it back where it needs to go.
Note that in many cases, the tinymce initialize code only runs on page load. I think that's what Loader::element('editor_init') does. And it works by detecting the appropriate textareas (based on class name). So if the page with the editor_init is loaded before the textarea is loaded (such as how it looks now), you'll have to reinit tinymce. That's a vote for #2. In general, I suggest you go that route.
Drupal 6.28:
I'm re-theming a particular section of a site and the new design called for five pages to be displayed as five tabs on one page with the appropriate one shown when either clicking on the tab itself or in an expanded menu to the left.
I created all that in html and jquery so that I could deep-link the tabs, ie... someone can click on any menu link and hit the page with the appropriate tab open instead of having to go to the master page and then click the appropriate tab. (using location.hash)
This is all working fine, but the last tab is to house content that currently is a view set as a block.
What is the best way to pull that view/block into the html div I have set aside for that specific content?
I have used this great snippet before:
<?php
$block = module_invoke('block', 'block', 'view', '15');
print $block['content'];
?>
which allows one to place any block anywhere, but with a view with a display set as a block, I'm not having any luck invoking that view. Also, I'd had to have to use "php" instead of 'full html' on the node since it's just a snippet but as it's not currently working, it probably doesn't matter.
so, I'm trying to figure out how to have something like this:
<!-- all the other tabs content-->
<div id="fifthTab">
all the content from the view which is set to 'display like a block'
</div>
I'm fairly new to Drupal and not even sure if I create a page display how I would call that data anyway.
So my html structure is:
MAIN PAGE LINK
-sub link/tab 1/default
-sub link/tab 2
-sub link/tab3
-sub link/tab4
-sub link/tab5
So if someone either clicks on on the sub link/tab 5 in the left nav or clicks on the actual tab 5 or enters the url xxx/#tab5, the appropriate tab is show, the rest hidden. That's all working great, I just cant get the view content to show in that tab5.
so a page template based on the url is the easiest. The variable $content is just placed in the last tab and all other html content for that specific page is just put in the template.
At least this way, as docs are added, it's still dynamic and the static info is easy to edit if needed.
Just in case something similar comes up for someone else.
When you open the yahoo main page at the top there is a search section that contains links like: Web, Images, Video, More
When clicking on the link the chosen section is activated and the text of the search button is being changed. The only part of the page that is updated is the search part at the top and the other parts of the website remain unaffected.
My question is how is this implemented? And more importantly how similar behaviour could be
implemented in .net using VS 2008?
Are the links really links or different elements that only mimic the links behaviour?
Does it need to be ajax, or just everything is preloaded and hidden using some css techniques?
Is the same technique used in the news section on the same page when changing tabs: News, Sport, Entertainment, Video?
Thank you
This is actually done with CSS and Javascript:
<ul id='menu'>
<li><a href="#web_search" class='active'>Web</a></li>
<li>Image</li>
<li>Video</li>
<li>Local</li>
</ul>
<div id='web_search' class='search'></div>
<div id='image_search' class='search' style='display: none;'></div>
<div id='video_search' class='search' style='display: none;'></div>
<div id='local_search' class='search' style='display: none;'></div>
Then Javascript (example uses jQuery, can be done many ways...):
$('a','#menu').click(function() {
$('div.search').hide();
$('a.active', '#menu').removeClass('active');
$($(this).addClass('active').attr('href')).show();
$(this).blur();
return false;
});
And this is an example of it in action. The styling and such would all be CSS.
After doing a quick inspection of the search field using Firebug, it appears that clicking on each of search type links (Web, Images, etc) simply modifies the DOM. This includes adding fields, removing fields, toggling class names, etc. I wouldn't be surprised if hidden fields are also being manipulated.
Behavior like this is accomplished using JavaScript. Specifically (and at a very high-level), there are event handlers attached to the links each of which modify the DOM in their own way.
It can definitely be implemented using Visual Studio 2008 as it's really (and likely) nothing more than CSS, JavaScript, and HTML. .NET really wouldn't come into play until you're ready to take the specified query and begin running it against your data store.
Paolo's answer gives a really good, straight-forward example of how that behavior can be emulated.
Those links have onlclick JavaScript handlers attached to them. When you click on them different tab becomes visible and current tab gets hidden. All tabs are preloaded but only the first one is visible initially.
Take a look at Tabs control from ASP.NET AJAX control toolkit. You can customize tabs so that they look like links.