I'm working on a CMS and would like to configure cake to automatically find the proper page to use based upon the URL. I don't want to have to manually set this and want it to automatically work if I create new pages (based upon slugs).
Let's say I have the following "page layout":
News
-Local
-World
-article1
Products
-Product1
-details
-photos
etc
So: mysite.com/local/world/article1 would load "Article1". If I added a page under article1 titled "photos", then: mysite.com/local/world/article1/photos would work. Also, mysite.com/products/product1/details would work, etc. Any page I add to the site should be available (it should use a parent/child method). Any tips on making this happen with CakePHP?
Related
I have the following challenge:
I have a Moodle system and would like to track visitor activity in the courses via Matomo.
The problem is that one course has several activities, but they are found under a different URL structure.
Example: My course has the URL /course/view=1 and also has a few activities that can be found under three completely different URLs (e.g. /mod/forum/view=20, /mod/feedback/view=7 and so on).
Now I would like to have a common tracking for a course room and the activities in it.
Is this possible? Are there any direct solutions for Moodle? Or how could I do this manually in Matomo?
Thanks
It's possible to set a custom URL in Matomo by using the following code in the page:
_paq.push(['setCustomUrl', 'https://yourdomain.com/your-new-page-url']);
You could perhaps do this for all the pages within a "Course" in order to track all of the actions taken in one logical "Page", but this may affect some of the reports for that page (For example page overlay might be broken)
An alternate way of tracking all of the actions would be to set the Page Title that Matomo tracks using:
_paq.push(['setCustomTitle', 'Your Page Title Here'])
This will allow you to group all of the actions under one logical Page Title under the Page Titles report.
I've been using wagtail-modeladmin to create custom lists of certain page types. That gives me the ability to edit those pages. But I'd also like to be able to click through somehow to the "normal" admin explorer version of those pages, and be able to view/add child pages to them.
essentially giving myself a column with the little arrows in on the right, just like in the normal wagtail admin page explorer...
OK I know it's bad form to answer your own question, but I've got this working by using a custom method on the model admin object that reverse wagtails admin urls:
class MySpecialPageModelAdmin(ModelAdmin):
def view_children(self, obj):
url = reverse('wagtailadmin_explore', args=[obj.id])
return format_html(f'View Children')
list_display = ('title', 'live', 'view_children')
but actually, I think I'm not going to end up using this, just replacing this particular modeladmin with a direct link to the right place in the explorer.
How do I extract specific field for display in a taxonomy page?
I have a custom content type called "film" and each film has a Term Reference field called "casting". As expected I can click on a "casting" (tag) it brings me a page where all films are listed wherever this tag is associated. For expample if I click on "Kate Winslet" from movie Titanic, I land on a page http://localhost/mysite/tags/kate-winslet where other movies of Kate Winslet are listed. Up to this point everything is just fine.
I do not want Drupal to pull in and show default fields like just Title and Body in its own display format. Rather I want it so that I can display a photo from each film, year of release and of course the title and trimmed version of the body. I only want to customize the content of this page so that I have the control over What to Show and Where To Show a specific field value.
This is what I tried:
I cloned and put page.tpl.php in my theme's template folder. Renamed it as page--vocabulary--tags.tpl.php. Then I took out the following line of code (<?php print render($page['content']);?>) from my page--vocabulary--tags.tpl.php. The intention was to check whether the overridden template is actually being accessed by Drupal or not. It does!
But I am not been able to extract fields like field_photo or field_release_date from $page['content]. To get an idea about defined variables and how they are placed I used the following line of code:
<pre><?php /*print var_export(get_defined_vars(), TRUE);*/ ?></pre>. But even from there I could not extract a particular field like I mentioned above. The fields look to be somewhere inside $page['content']['system_main']['nodes'], but I don't know how to get to a specific field directly.
I also created a template.php with the following preprocess hook function:
<?php
function introduction_preprocess_page(&$vars) {
if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
$term = taxonomy_term_load(arg(2));
$vars['theme_hook_suggestions'][] = 'page__vocabulary__' . $term->vocabulary_machine_name;
$vars['content'] = $vars['page']['content']['system_main']['nodes'];
}
}
?>
Both <?php print render($content) ?> and <?php print render($page['content']) ?> print the same result but I want something like <?php render($content['photo_field'])?> which I am not been able to.
I am sorry for making this too long. I have just stepped into Drupal. So wanted to make sure that what I am trying to explain matches exactly what I want to accomplish.
You are probably trying the long way to this.
You can use Views module. It allows to create custom listings querying the database, but also override existent ones, like the case of the taxonomy term page listing.
Once you have the module installed (if it's not yet), particularly the Views UI module, go to /admin/structure/views and scroll to bottom, where disabled views (grayed rows) are. You'll find one called Taxonomy term, described as 'A view to emulate Drupal core's handling of taxonomy/term.'
Click Enable on the right of it and then go to the same place where the Enable link is, click the arrow to unfold and choose Edit.
Once you're in the view edit page, you can manipulate the listing at your convenience, adding/removing fields or whatever you want to do in your particular case. If you are not familiar with Views, I recommend you to learn about it, there is a lot of related content on the web and it is close to essential for Drupal development.
Also, if you want to add more customisation to the page, you can use the same approach with the Panels module, who allows to override system pages (not just listings like Views).
I have been trying to create a component like the Bakery's Paginator Recall that would allow me to save pagination data for CakePHP 2.4 and run into the following issue.
All solutions involve saving the Paginator parameters in the session and then retrieving and applying them upon returning to that same page without specifying any.
This approach would have worked if only the Paginator helper functions like numbers(), first() and previous() would include the page:1 named parameter in the links that they generate for moving to the first page like the corresponding function of the 1.3 version.
Unfortunately all of these functions create URLs without the page parameter when they refer to the first page, so when users click on the first page link, the component does not find any paging info and hence it returns them to the previous position.
There must be some way to work around this, but for the moment I am completely stuck.
NOT including the page number in the link to the first page is by design.
Read the reason on the CakePHP 2.4 Migration guide.
I would suggest to use the same convention. When you do not have pagination information assume is page one, and do not add it to your URLs.
So all you have to do is code this special case when then pagination is missing. And in this special case your "recall" component will simply not add that page.
I believe that I have managed to create a working solution. Thanks to the advice I have received I have now created a working component like the original PaginationRecallCompoent.
I have written all the details in the following blog post.
I am new to pyrocms.
How can I get database values on pages of pyrocms. In website of pyrocms I had created a listing page now I want to display database values from pyro database table.
I got your question, you want to create a listing on your front-end page for some database table values which you want to access through your custom module controller. there are many ways to get these values but the simplest way is to use ajax. you already have Jquery added in pyrocms so you can simply make a call to your controller method in ajax and get your required output as HTML and display it in the div element on your page.
$.ajax({
type:"POST",
url:"admin/your-controller-name/your-method-name",
success:function(html){
$('yourdiv').html(html);
}
})
In your controller create a method which get data from database and print it using echo create some listing table etc what you want.
i think you will get my point. if confuse then get back to me
You need to be more specific as PyroCMS has lots of components and each module (blogs, variables, widgets, file uploads etc.) uses specific tags you insert into the page. You may come across references to 'Lex' - that's the name of the parser used to display them.
Tags documentation
PyroCMS (the Professional edition) also has a feature called "Streams" which allows you to build custom databases and this in turn has it's own series of tags.