How to set the format of a <$view > to wiki in tiddlywiki? - tiddlywiki

In my tiddler, I have the following field:
name : my_field
value : [[Some Page I Want To Link To]]
Then, in the same tiddler, I use the following ViewWidget to see the content of the file:
<$view field="my_field" />
The problem is that the rendered text is not wikified, and thus, there is no link despite me having wrapped the name with [[ and ]].
How can I do to have my text rendered as a proper link?
Note: Removing the spaces is not an option.
P.S.: Of course, I tried the documentation, that is:
http://tiddlywiki.com/#ViewWidget
http://tiddlywiki.com/#LinkWidget
... including changing the format, etc., but to no avail.

The solution is to use the transclude widget, instead of the view widget:
<$transclude field="my_field" />

If your field my_field has the value: Some Page I Want To Link To
Then use:
<$link to={{!!my_field}} >{{!!my_field}}
</$link>

Related

How to check if div contains text (XPath)

I use https://autorefresh.io/expressions/ chrome extension for page refreshing. The next level for me is checking if a specific page part contains the predefined text. This extension supports XPath.
I was trying to use //*[contains(text(),"Brak towaru")]. It worked until I put this cell "address" instead of *.
/html/body[#class='b--desktop breakpoint-xl']/div[#class='body-inner']/
section[#class='pt-2']/div[#id='main']/div[#class='shop']/
div[#class='row mt-4 justify-content-center'][1]/div[#class='col-4 col-md-2 pt-3 text-center']
I was trying to insert this "address" in many ways... No success.
Any hints?
screenshot of XPath extension
Instead of using contains(text()) try using contains(.,). This will check for text content in the element itself and in it's child nodes.
So, instead of
//*[contains(text(),"Brak towaru")]
Try using
//*[contains(.,"Brak towaru")]
And in case this is a div element use
//div[contains(.,"Brak towaru")]
Thank you very much. Works :)
//*[#id="main"]/div/div[3]/div[3][contains(.,"Brak towaru")]

CKeditor 4 replace config param for each field

I got 3 textarea on page.
It's conected with CKeditor. also got CKeditor plugin on it.
I wish to have different characters count for each field.
Now I give it in config for all of them:
CKEDITOR.config.wordcount.maxCharCount=30;
to sum up:
how I change config value for one field in ck'editor
You should be able to use the tag MaxLength on each individual control.
<cke:CKEditorControl ID="ckeText" Toolbar="" AutoGrowOnStartup="true" MaxLength="5" runat="server" />
You can also find all of that information on their documentation website docs.ckeditor.com

Xpath: getting data by comparing attributes

I need to assign an XPath expression to а reference tag which will generate automated text near my reference. The generated text should be taken from the title of the target element(figure).
This is how it looks.
Reference construction(could be located anywhere)
<internalRef internalRefId="fig1"></internalRef>
figure construction(may be anywhere)
<figure id="fig1">
<title>The TEXT I TRY TO GET
</title>
...
</graphic>
</figure>
I guess i should take the "title in figure" tag content if the figure's id attribute matches the link's target attribute.
One of my fail expression variants that prints nothing
//figure[self/#internalRefId=#id]/title
Thanks for ideas...
You're searching for #internalRefId attributes inside some non-existent <self/> element. Use you write the <internalRef/> element "could be located anywhere", this should be fine:
//figure[//#internalRefId=#id]/title
This will return all title elements for figures that have an #id equal to any #internalRefId attribute anywhere in the document.

Customize a document_view and add a div?

This feels like a newbie question but:
I am trying to create a new page from the drop-down display menu so that I can supply a background color to the page (so end user doesn't have to go into the html and add a div). I tried adding a new (empty) div to the template but it's not working. Is this even possible?
Here is my code (my div is called "s_holder"):
<metal:field use-macro="python:here.widget('text', mode='view')">
Body text
</metal:field>
<div metal:use-macro="here/document_relateditems/macros/relatedItems">
show related items if they exist
</div>
<div tal:replace="structure provider:plone.belowcontentbody" />
</tal:main-macro>
</metal:main>
<div id="s_holder"></div><!--end s holder-->
</body>
</html>
For the part of creating the new display view: as #Auspex said, you should put the div inside the macro.
To add your display view to the drop down menu you need to edit every content type. There are two ways of doing this:
1- manually add a "types" folder in the genericsetup profile of your product and put inside one xml file per content type. Ex:
File.xml
<?xml version="1.0"?>
<object name="File"
meta_type="Factory-based Type Information with dynamic views"
i18n:domain="plone" xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<property name="view_methods">
<element value="file_view"/>
<element value="myniewfantastic_view"/>
</property>
</object>
2- in the ZMI -> portal_types edit every content type to add your display view and then in the portal_setup tool export the step for types. Extract the xml definitions from the downloaded archive to your genericsetup profile (in the "types" folder) and then edit them to remove unuseful parts as above.
Sure you can do it. I'm not convinced it's a good idea :-), but you need the <div> to be inside the main_macro (your example HTML is invalid - you have a </tal:main-macro> and no start tag, but I'm assuming you just cut and pasted the last part of the template here, because that template would never display, if it was written that way.
That said, how exactly are you adding it to "the drop-down display menu"?

Blogger template: Style blog post based on label

I'm trying to change the style of a blog post (for instance change the title color), based on the labels associated to the post.
I'm a bit new to the templating, so I though I would be going to add a class with the label in the title <h3> element, and then add my CSS rules.
So I found this which would generate a proper list of labels separated by a space:
<b:loop values='data:post.labels' var='label'><data:label.name/> </b:loop>
However, it seems the validator does not let me add this inside the class attribute as follow:
<h3 class='post-title entry-title <b:loop values="data:post.labels" var="label"><data:label.name/> </b:loop>'>
From there, I found half the solution. Apparently, I should use expr:class instead of class as follow:
<h3 expr:class='"post-title entry-title " + data:list_of_labels'>
So now:
- How can I build this variable data:list_of_labels? (basically how to set a variable)
- Is there a full description of the template syntax somewhere?
- Is there another way to go around this?
Thanks,
JB
This should do it. Using XML entities allows you bypass the XML validation and move the Blogger functions to where you need them. Longer explanation here: http://www.karlhorky.com/2012/06/add-blogger-labels-to-post-as-css.html
<div class="post<b:if cond="data:post.labels"><b:loop values="data:post.labels" var="label"> <data:label.name></data:label.name></b:loop></b:if>">
<data:post.body>
</div>
There is no way to set variables in the blogger data xml, however you can set variables using javascript.
There are many pages on the blogger data xml. Google is your friend. For example this one.
You are on the right track: do a loop, use javascript to check for the combinations you want, change the style properties or load a css file dynamically.

Resources