Hook active trail path views Drupal7 - menu

I' am trying to make a custom module to set an active trail path to a menu.
I created a views page.
The active trail must be to a node or taxonmy term.
When I open the pages created by the view the active trail is not active.
I wrote the script here below but it doesn't work, can somebody please help???
function mymodule_views_default_views(&$view, &$display_id, &$args){
if( $view->name = 'productdetail';)
{menu_tree_set_path('menu-categorie', 'node/39');
}
}

Script is the wrong word, I used views and added the fields as mentioned above.
Sorry for the misunderstanding. I hope it helps.

I am happy, I have found the answer to my own question.
I like to share this answer, and hope, that this although helps others...
Here the answer:
In the view I added a field with the term-id / node ID which is although used for my menu and hide the output and do a rewrite of the output
I pasted the following code in text field for rewrite.
field_categorie-tid is my reference term from the menu
menu_tree_set_path('menu-categorie', 'taxonomy/term/[field_categorie-tid]');.
instead of taxonomy term you can although use node/[nid]
I added in the head section a global field
with php and token and put this script:
Thats all.
No hooks or custom scripting in template
I hope this helps someone else.

Related

Grav - Parse URL

I want to define a new template called "product".
This template calls an external service and retrieves the information about that specific product. That is easily done with a custom plugin that access the product information. Information on how to do that has been found here.
However, I would like that the URL of the page would be something like:
/product/<id>/<seo-friendly-description>
So I can retrieve in the Twig template both <id> and <seo-friendly-description> which will be used later to retrieve the specific product information.
I have tried to find something that could help in the documentation, without success. Could someone either point me to the right doc section or highlight the basic steps that shall be achieved so I can start solving this issue?
Just in case it helps, I am trying to find something similar to how bottle or other web frameworks work:
#route('/hello/<name>')
def greet(name):
return 'Hello ' + name
I've been building a family recipebook into my own website and I've been working through a similar problem. I haven't quite worked out all the kinks, but my solution is mostly working if you want to checkout my github repo.
In short, you need the plugin to watch what the active route is. If the route matches, you then create the page and populate it using your plugin data.
I haven't quite figured out how to get the active page to highlight in the navigation menu for generated pages, but you might still find this solution helpful.

Add a comments section to post/pages on apostrophe cms

I need to build a comments section on my apostrophe for users to be able and leave comments/feedback around content that someone will create in pages. That would require to create collections in the database as well as allow users to comment only but not to remove any the module/widget. Also, comments need to, of course, be linked to pages.
Not really sure, how I can approach this task. Whether, to build a separate microservice or a widget to handle this. I have read the tutorial for building a contact form in apostrophe, also tested. However, I don't really need to have an option on the Admin Bar as comments are linked to each page, I need the form to be static (don't want any users to remove them or add more than one on a single page), also want the comments to appear below the form once they have been submitted.
Any idea of how I can do this?
Thank you for your time.
Dcram
EDIT
Well, before I needed to do this for pages and I even managed to post the comments specific for each page where it should be. However, needed to make a few changes on my site and now this comment widget appears in pieces like blogposts! However, haven't being able to display the specific comments for each piece. Is there any way I can find the piece page url similar to data.page._url so that I can compare with the one attached to each comment?
Thanks!
We almost always use Disqus for this purpose, but if you need a commenting functionality that is internal to your site, there is the apostrophe-pieces-submit-widgets module that can be extended for this purpose.
You would definitely want the comments to be an instance of an apostrophe-piece in the docs collection, which would mean it would by default be included as an item in the admin bar. Easy enough to hide that, however.
Following this pattern would result in creating / configuring 3 project-level modules:
comments - extends apostrophe-pieces, defines the comment piece type
comments-widgets - extends apostrophe-pieces-widgets, a widget to display comments on a template (you could also hard code this behavior into a template instead of making it a widget)
comments-submit-widgets - extends apostrophe-pieces-submit-widgets, a widget to display the front-end form that users use to submit their comments
Building this sort of functionality directly into a piece and its widget player is not too difficult, check out this project for more
https://github.com/stuartromanek/apostrophe-comment-system
Steps:
Checkout project / install / create user / get up and running
Create a Comment piece from the admin bad (Home Page Comments, for example)
Add the new piece to singleton widget on the homepage
Comment!
This code should give you a pretty clear guide for creating backend functionality that can be interacted with on the frontend.
Permissions for interacting with the widget itself should be managed through apostrophe-permissions http://apostrophecms.org/docs/tutorials/intermediate/permissions.html

Mod x Page not updating

I've created a snippet and included it on my template and when I make changes to the file it does not show. If I view the snippet it looks like it has changed
This is my snippet (really simple):
echo date();
This is my update:
echo rand(0, 1000);
Shown above is the change however in my template it will not change.
I know this might seems stupid (it is). However I hope you can help.
If partial cache is enabled then you will find you will have to clear the Modx cache manually.
To do this, log into the admin area, and go to:
Site -> Clear Cache
I had this problem again, then I realised the template wasn't linked to a static file.
So if this happens to you, check your template.

Set a navigation node in the impex to have no anchor / be a heading

I am working on a navigation IMPEX for hybris (not really confident with it, sorry!), and would like to have some of the nodes be headings rather than a link. Setting them with no link reference means that go nowhere but they are still anchors and hence the cursor changes, confusing users. Is this possible from the IMPEX file? Thanks in advance.
May be you need to modify the navigationbarcomponent.jsp.
Check the link has url then call linkcomponent or else just place the name of the link.

Change template html in sharepoint discussion reply box

I have a wss 3.0 install which needs an "anonymous" discussion board. I can modify the view so no usernames are displayed, however when I click on "reply", the message I'm replying to shows up in the rich text box with the username of the previous poster.
Is there a way to remove that username? or Remove the previous posted text altogether? I've found the schema.xml file with lots of relevant info under the ..12\TEMPLATE\FEATURES\DiscussionsList\Discuss folder, but not sure if this is the easiest way to adjust this setting.
Any comments appreciated.
Best practice says that you should always create a custom list definition instead of trying to modify the OOB assets.
The easiest way to do this is take a copy of the 12\TEMPLATE\FEATURES\DiscussionsList\Discuss folder, modify the feature Ids and names so that its unique. Then your free to change the schema render template (i.e view schema) and modify the edit and display forms.
If you need to modfify the actual entry form you may consider a custom control template : http://msdn.microsoft.com/en-us/library/aa543922.aspx
Custom list definition : http://msdn.microsoft.com/en-us/library/ms466023.aspx
Agrothe,
I have a similar requirement (hide or mask the author inside the reply thread.). What exactly inside of schema.xml do you think will allow you to do accomplish that?
Not sure if the list forms are exposed to xslt. If so, then perhaps this is another approach.
FWIW, the other solutions I have investigated:
(1) A custom event handler. Unfortunately, I can't pinpoint which event fires when someone click reply.
(2) Anonymous blog comments (http://blogs.msdn.com/sharepoint/archive/2007/08/06/anonymous-comment-feature-for-sharepoint-blog-now-available-on-codeplex.aspx).
(3) the other thing I am considering, is to introduce a global anonymous active directory login, which users can use to post anonymously. Not ideal, but for the amount of time I have spent researching a solution, might be my last hope.

Resources