Changing the format of the URL in Nette Application - nette

I am new to Nette.
I have the router set up as
$router->addRoute('<presenter>/<action>[/<id>]', 'Home:home:default');
In common.neon I have the mapping set to:
*: App\Modules\*\Presenters\*Presenter
The site is set up as modules.
In order to get to a page the URL is in the format of
http://192.168.56.30/home.signin/
I am wanting to change it so the format is
http://192.168.56.30/home/signin/
The home.signin format is also how it is presented when using the n:href in latte file
<a class="nav-link active" n:href=":Home:Signout:default">Sign Out</a>
this is translating to home.signout for example.
Is there a way to fix this so its in a nicer format?

Try this code:
$router->addRoute('<module>/<presenter>/<action>[/<id>]', 'Home:home:default');
Or you can use $router->withModule('Home') method (see https://doc.nette.org/en/application/routing#toc-modules for details).

Related

Vue using a method in a v-for statement

Can I use a method in a v-for statement. For Example
<li v-for="attach in item.attachments.split(' ')" :key="attach">
{{attach}}
</li>
Or do I need to split the item.attachments and set it as a different property that is a list
I can do exactly what I asked. My issue was the field needed to by split by new line feed and not a space.

Facebook Open Graph Story Determiner not working

I am trying to use 'the' as the article for my object, but FB is simply ignoring it and is using 'a' instead.
When I run the object's url in FB's debugger I see all the info that's necessary. All the other properties are being used just fine.
Anyone have any idea why this is happening?
Object types cannot use "the", only "a/an". So if your determiner isn't showing when not using the object's title, that's why.

CMS links on frontend not converting ie href=[sitetree_link_id=xx]

An issue has been noticed on one of our old sites running 2.4 where when the user creates a link in the CMS content, selecting an existing page to link to, the link is not being converted to the actual URL on the front end and all links are coming through in the format of <a href="[sitetree_link_id=12]">
What would be causing this and how do I fix it?
The tag looks like it's being set incorrectly. It should be [sitetree_link id=12], not [sitetree_link_id=12].
We later added support to the parser for [sitetree_link,id=12] so that links didn't need to contain spaces, but I can't recall if that's in 2.4 or only 3.0+.
Can you confirm that your WYSIWYG insertion is putting in that errant _? If so, you might want to checkout the handleaction_insert function in tiny_mce_imporvements.js to confirm that it has a line like so:
case 'internal':
href = '[sitetree_link id=' + this.elements.internal.value + ']';
If the inserted links don't actually have the errant _ but they aren't being parsed, then try checking your sapphire/_config.php file for this:
ShortcodeParser::get('default')->register('sitetree_link', array('SiteTree', 'link_shortcode_handler'));
If your site makes changes to the ShortcodeParser at all you might have inadvertently turned off sitetree_link support.
If all of that looks in order, perhaps the ShortcodeParser isn't being called for some reason. In HTMLText::forTemplate(), put a debug statement (I like die("I got here!");) to confirm that HTMLText::forTemplate() is actually getting called. If it's not, you might need to manually call it in some pre-processing of your Content variable. Instead of this:
$content = $this->Content;
Do this:
$content = $this->obj('Content')->forTemplate();
I hope that one of those answers help. Either way, it would be great if you could post back, so we could isolate what caused this. It might help us make the API easier to use in SilverStripe 3.1.

Can more than one author be listed in the byline?

I'm using Plone v4.1.2, and I'd like to know if there a way to include more than one author in the by line of a page? I have two authors listed in ownership, but only one author is listed in the byline.
I'd like the byline to look something like this:
by First Author and Second Author — last modified Jan 11, 2012 01:53 PM — History
UPDATE - Thanks everyone for your replies. I managed to bungle my way through this (I've never used tal before). I edited plone.belowcontenttitle.documentbyline as suggested by Giaccamo, and managed to learn a bit about tal along the way. Here is the code that does what I needed (this replaces the existing tal:creator construct):
<span>
by
<span class="documentCreators"
tal:condition="context/Creators"
tal:repeat="creator context/Creators"
i18n:translate="text_creators">
<span tal:define="cond1 repeat/creator/start; cond2 repeat/creator/end"
tal:condition="python: not cond1 and not cond2" >, </span>
<span tal:define="cond1 repeat/creator/start; cond2 repeat/creator/end"
tal:condition="python: not cond1 and cond2" > and </span>
<tal:i18n i18n:translate="label_by_author">
<a href="#"
tal:attributes="href string:${context/##plone_portal_state/navigation_root_url}/author/${creator}"
tal:content="creator"
tal:omit-tag="python:view.author() is None"
i18n:name="author">Roland Barthes</a>
</tal:i18n>
</span>
</span>
This puts the userid on the byline instead of the full name. I tried to get the full name, but after some time without success I decided I could live with userid.
In order to browse more than one author you'll need a little bit of coding:
That piece of page is called viewlets.
That specific viewlet is called plone.belowcontenttitle.documentbyline.
You can use z3c.jbot to override the viewlet template. Take a look at this howto for usage. Another option is to customize the template through-the-web following this tutorial.
you could use the contributors- instead of the owners-field. they are listed by default in the docByLine. hth, i

Override only the Description field of the Plone standard content type

I would like to ovverride only the "view" of the classic "description field" of the Plone standard content type (Document, Folder, blabla), cause I need to "structure" the text of this field with structured text like:
This is my description<br/>
with many lines<br/>
bla bla<br/>
Changing the template that renders the standard description field to convert newlines to breaks isn't hard, but will require a little care to avoid creating a security hole.
Override the skin layer kss_generic_macros.pt template, either in a theming product or the custom folder.
Then, you may use Products.PythonScripts.standard.newline_to_br to convert newlines to breaks. You'll need to insert the converted text with "structure" to prevent escaping of the breaks.
Since you'll be using "structure," you absolutely must also manually html escape the description (use html_quote from standard) before applying newline_to_br, or you'll create a vector for a XSS attack.
The key section of the macro, when fixed, might read:
<div metal:define-macro="description-field-view"
id="parent-fieldname-description"
tal:define="kss_class python:getKssClasses('description',
templateId='kss_generic_macros', macro='description-field-view');
pps modules/Products.PythonScripts.standard"
tal:condition="context/Description"
tal:attributes="class string:documentDescription$kss_class;">
<span metal:define-slot="inside"
tal:replace="structure python:pps.newline_to_br(pps.html_quote(context.Description()))">Description</span>
</div>
You really don't want HTML in the description field. This field is used in a number of places and expects plain text.
You are best using the approach above to add an additional field with a different name.
If you want to customize the description widget for all content types you could create an adapter using archetypes.schemaextender (notably the ISchemaModifier interface) like this:
from my.product.browser.interfaces import IMyProductLayer
from my.product.widgets import MyCustomWidget
from Products.ATContentTypes.interface.interfaces import IATContentType
from archetypes.schemaextender.interfaces import IBrowserLayerAwareExtender
from archetypes.schemaextender.interfaces import ISchemaModifier
class MyExtender(object):
# you could choose a more specific interface for a more fine grained override
adapts(IATContentType)
implements(IBrowserLayerAwareExtender, ISchemaModifier)
# this will limit out override to this browserlayer
layer = IMyProductLayer
def fiddle(self, schema):
# if you want to customize just the template of the original widget
# see links below
schema['description'].widget=MyCustomWidget(
label='...',
....
)
return schema
and then you can register it like this:
<adapter
factory=".extender.MyExtender"
provides="archetypes.schemaextender.interfaces.ISchemaModifier" />
Don't forget to register your browser layer IMyProductLayer or this adapter will never be used.
More info:
http://pypi.python.org/pypi/archetypes.schemaextender
http://weblion.psu.edu/services/documentation/developing-for-plone/fsd-extender/hiding-fields
https://svn.plone.org/svn/archetypes/MoreFieldsAndWidgets/Products.MasterSelectWidget (a custom widget example)
http://docs.plone.org/old-reference-manuals/plone_3_theming/buildingblocks/skin/templates/customizing-at-templates/customizing-widgets.html (customize just the template of a widget)

Resources