DotNetNuke Switching Between Multple Edit Modules - dotnetnuke

I have a custom module in DNN 7 that has a data structure where items belong to categories (called "sections", not DNN taxonomy, just a simple list of section names). The module edit screens work so that on the view control you may click on an edit link on each category, which loads the category edit screen (passing the category id). This works great, and when you save I use Globals.NavigateURL() to return to the view screen. This all works as intended.
On each category edit screen I also have a list of the items within that category, each with an edit link. Clicking the edit link opens the item edit screen, passing the correct item id, and allowing me to edit that item. This all works great, until you save. The save works properly, but when I want to send the user back to the edit screen for the category it doesn't work. When I use:
Response.Redirect(EditUrl("SectionId", sectionid.ToString(), "EditSections"), true);
...nothing happens. It simply doesn't redirect anywhere. This is exactly the same URL I'm using to get to the category edit page in the first place:
EditUrl("SectionId", Eval("SectionId").ToString(), "EditSections")
And then I use a similar URL to get to the item edit page:
EditUrl("ItemId", Eval("ItemId").ToString(), "EditItems")
I don't understand why using the same URL to navigate to the same page I already navigated to would simply not do anything. For now I am sending them all the way back to the view, but it's painful if you need to add several items to the same category to have to navigate back into the category and add another item, only to be sent back to the view.
Anyone see anything like this before?

Have you tried to use the overload of NavigateUrl instead of EditUrl?
Globals.NavigateURL(TabId, "EditSections", "mid", ModuleId.ToString(), "SectionId", Eval("SectionId").ToString())

I haven't seen that myself but I would have to assume that somehow the context is being lost with EditURL and you're not getting sent to the proper location due to that.
I would suggest you try one of two things (or both).
Debug the URL that EditURL is returning and see if you can find the
difference.
Use NavigateURL for all your links and pass in MID=## for your
moduleid as a querystring parameter, to ensure that the proper
values are being passed.
UPDATE: If you're trying to have multiple edit views, and move between them, you might look at using a "loader" instead of having separate module definitions for the edit controls. Basically have a single Edit.ascx file defined, and it loads other ASCX files within it, injecting into a Panel. The View control on this module http://dnnsimplearticle.codeplex.com/ does that, but I haven't tried it with an edit control before.

Related

Drupal 7: How do I extract specific field in a taxonomy page

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).

Changing states without reloading previous view data when I go back to it

I am new to angular and was wondering if I could somehow change states (after clicking on link from a list of search results) and load a new view, hide the old one (including header !), but not unload it/not have to request JSON data again if I got back to the search results for products view from the product details view.
Well, this will be a really short answer.
Take a look at this:
$templateCache You can play around with it so you won't need to reload pages when going back and forth.

Angularjs: how to pass entire object to another controller?

OK, I'm very new to AngularJS. I'm converting a rather rough-app (that I've been writing for a couple of days) from using mostly jQuery over to using Angular. [ I discovered Angular "mid-stream", while researching how to alleviate all the bookmark and back-button headaches I was running into.]
On my main page, I have a table of search results. (If the user arrives without passing any parameters, a default search is called to build the table. And, of course, they can use a search form on that page to show themselves a different set of results.)
Now, when the user clicks on a table item, I want that table to more or less "become" a drop-down menu on the Item Details page that can be used to navigate from one table item to the next. (The list will usually be less than 20 items long at any given time.) Same data, same sort order, just in a different control.
Rather than build that "Child" page so that (in addition to making Ajax calls to pull up the item details) it runs the exact same query AGAIN and then builds a drop-down out of it... I thought perhaps there was some more-efficient way to do it.
Perhaps, pass the entire object of objects from the search results on to the Details controller? (I would somehow have to also pass an id for whichever item the user actually clicked on for details as well.)
[With jQuery, I had been building both the drop-down and the table of results on the same page...and then just use show() and hide() to alternate which one I was displaying. And I would fetch the Item Details data and populate/show hidden details divs whenever a table row or drop-down option was selected.]
First I think you should use some kind of routing, maybe this can be helpful
https://github.com/angular-ui/ui-router
And second one, if you want to access same object with multiple controllers, you should use factory with your object, and all you need is to inject that factory into your controllers, and you will have access to the same object from multiple controllers. Here is the short tutorial, it's very easy to understand:
https://egghead.io/lessons/angularjs-sharing-data-between-controllers
And third option, but it's not nice, is to emit or broadcast event and send object from one controller, and in another one you can put a listener for that event, here you can find more information:
http://www.theroks.com/angularjs-communication-controllers/
http://toddmotto.com/all-about-angulars-emit-broadcast-on-publish-subscribing/

AngularJS - how to use a route with dynamic data for template

I'm not sure what I'm fully after really hence this could easily be a duplicate of another topic - if so please direct me :)
Anyway, what I want to do is something like a shopping page, where there is a page listing out all the items. This part I can do fine :)
The issue I have is I only want one page which "details" each item - as they all share the same layout. So in this case, depending on what's selected, it routes to a details page (maybe with corresponding ID of some sort) that displays the details of whatever clicked.
Is this possible? Hope I've explained this well enough - if not please let me know.
TIA
You don't need to use a route for each item. You can use a route for the page itself (with ngView, for example) to present the details page, and then (assuming you have an object with the data) you present the current item's model appropriately.
If you can present some code I can give you a better idea.

Render a page differently based on which list that opened it

I have two lists of different PageTypes - NewsItems and PressReleases. They are displayed in one list each, with links to the individual items.
Now I want to include the press release items into the news list and use the style of the news items to display them as news items. They share properties like "Heading" and "BodyText", which are used in the News Template.
I imagine that it won't be that difficult to feed the NewsItems' ListPage with both sets of pages, but I don't understand how I can control the rendering of the item page.
I would like to take the PageData object from a NewsItem OR a PressReleaseItem and display it using the News-Item.aspx template, if it is selected in a NewsList. But EPiServer will always render the PressReleaseItem with the PR-Item.aspx since it's coupled in the PageType settings.
Anyone know how to accomplish this?
EDIT: An effort to clarify:
The important issue is how to know the "list parent" and choose the right template from that. In the ListPage I can apply different looks on the PR and News items respectively using tompipes answer, but when selecting to see an individual item EPi will render the PR-Item-1 the same way regardless of their "list parent". That's the problem.
I'm not following exactly what you are attempting here. But I think I get the gist of it.
Why not use one aspx template for both page types, but in the code behind switch off sections using the visible attribute.
If you are using PageTypeBuilder you could use the "is" keyword:
somePlaceHolder.Visible = CurrentPage is NewsItemList;
If you're not using PTB, you could use something like:
somePlaceholder.Visble = CurrentPage.PageTypeID == 10;
or
somePlaceholder.Visble = CurrentPage.PageTypeName == "NewsItemList";
I'll point out now I'm not a fan of hardcoding anything, so I would place the template name, or ID into a config file, or a property on the start/root page to avoid hardcoding them.
Let me know if this will help, or if I have misunderstood please try elaborate on your issue.
Depending on how much the templates share you could go with user controls, placeholders or even different masterpages to switch view in a suitable way.
To know when to switch you could use a querystring parameter, session variable or the nicest looking way would probably be to lookup and get the list's PageData object by the HTTP referrer. If it's empty you will get press release rendering as the worst case.
I tried lots of solutions, including the adding of querystring to the PR items in the list links, the getting of referring url in the item template and different types of event hooking for automatic publishing of news items from a PR item (although I only looked at the code samples for that one), and finally came to the conclusion that they all had something that told me not to go that way. (Making the code too complex, or the markup logic too hard to understand and so forth)
I ended up using Fetch data from another EPiServer page, and creating a "shortcut pagetype" in which I let my editors pick which PR item should be used as base for a news item.
This shortcut pagetype is called "PR-as-news-itemPage" and it is rendered with the same aspx as ordinary news items: News-Item.aspx. Having no properties of its own, it will take all relevant data from the PR item selected with "Fetch..."
To render PR items with all its properties I created an ordinary new pagetype called PR-Item.aspx. This renders the "Attribute 2" property, which is only rendered by PR-item.aspx, and not by News-Item.aspx.
(I could have gone even simpler, by letting the editors use the old News-Item page type and use the "Fetch..." property there, but I have some mandatory properties in that page type which I didn't want to make optional for this sake.)

Resources