CPT parent page to have child pages - custom-post-type

Can't find the solution to the following. My CPT has a slug which is a page. I use the following:
'has_archive' => false,
'rewrite' => array('slug' => '/admissions/connect', 'with_front' => true),
But when I add this, the /connect page can't have child pages which are not CPT.

Related

AutoMapper ProjectTo not loading navigation properties for conditional mapping

I have the following mapping for a property
.ForMember(x => x.Destination, opt => opt.MapFrom(x =>
x.Request.PurposeId == (int)PurposeTypes.PickUpShipment
? x.Request.RequestDestinations.FirstOrDefault().Destination
: x.Request.ShippingDestinationDetails.FirstOrDefault(dd => dd.ShippingAddressTypeId == (int)ShippingRequestAddressType.Destination).ShippingAddress.Destination
))
And the destination object map is like this
CreateMap<Destination, DestinationDTO>()
.ForMember(x => x.LocationCode, opt => opt.MapFrom(x => x.LocationCode))
.ForMember(x => x.CountryCode, opt => opt.MapFrom(x => x.CountryCode))
.ForMember(x => x.CountryName, opt => opt.MapFrom(x => x.State.StateShortName)); // this is not working
The problem is when I am using ProjectTo the CountryName is not loading because it is not loading the navigation property State of the destination, so x.State.StateShortName is coming empty.
And I found out the reason behind it, this is happening because I am loading the destination conditionally and because of this it is not loading the navigation property, because if I remove the condition and loads the destination like this it works
.ForMember(x => x.Destination, opt => opt.MapFrom(x =>
x.Request.RequestDestinations.FirstOrDefault().Destination
))
So basically ProjectTo is not loading the navigation property if the property mapping is conditional and not direct.
Is there any way I can achieve this?

Shortening blog post address in browser

I need to shorten address in browser in PrestaShop from "csblog/post" to "blog". Customer is using blog plugin "CS Blog" which generates both links and addresses.
csblog is module, post is controller.
scheme of address is /csblog/post/friendly-name
Already tried changing link and address schemes in plugin files and found where exactly it's done, but after changing module and controller - it crushes. It can't find posts or no page error shows.
Already tried various .htaccess Rewrite sentences in main app (in folder and in main folder of module. No effects.
No help in internet as this plugin seems not very popular.
This is my current code in .htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ csblog/post/([^&\]+)
RewriteRule ^blog/%1? [L]
How can I make this short address, should it be done with .htaccess or managed only via plugin?
Function that generates links:
{
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
$id_shop = Context::getContext()->shop->id;
$url = Context::getContext()->link->getBaseLink($id_shop).$this->getLangLink($id_lang, null, $id_shop);
$params['module'] = $module;
$params['controller'] = $controller ? $controller : 'default';
$dispatcher = Dispatcher::getInstance();
$dispatcher->addRoute('cs_blog_post', '{module}{/:controller}/{id_cs_blog_post}-{category_parent}-{rewrite}.html', null, 1, array(//{module}{/:controller}
'module' => array('regexp' => '[_a-zA-Z0-9_-]+', 'param' => 'module'),
'controller' => array('regexp' => '[_a-zA-Z0-9_-]+', 'param' => 'controller'),
'category_parent' => array('regexp' => '[_a-zA-Z0-9_-]+', 'param' => 'category_parent'),
'id_cs_blog_post' => array('regexp' => '[0-9]+', 'param' => 'id_cs_blog_post'),
'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*'),
), array('fc' => 'module',));
// If the module has its own route ... just use it !
if ($dispatcher->hasRoute('module-'.$module.'-'.$controller, $id_lang))
return Context::getContext()->link->getPageLink('module-'.$module.'-'.$controller, $ssl, $id_lang, $params);
else
return $url.$dispatcher->createUrl('cs_blog_post', $id_lang, $params);
}
Function that generates blog posts address:
public function hookModuleRoutes($params){
'cs_blog_post' => array(
'controller' => null,
'rule' => '{module}{/:controller}/{id_cs_blog_post}-{category_parent}-{rewrite}.html',
'keywords' => array(
'module' => array('regexp' => '[_a-zA-Z0-9_-]+', 'param' => 'module'),
'controller' => array('regexp' => '[_a-zA-Z0-9_-]+', 'param' => 'controller'),
'category_parent' => array('regexp' => '[_a-zA-Z0-9_-]+', 'param' => 'category_parent'),
'id_cs_blog_post' => array('regexp' => '[0-9]+', 'param' => 'id_cs_blog_post'),
'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*'),
),
'params' => array(
'fc' => 'module',
),
),
}
Routing is on your module's main file.
find function hookModuleRoutes on your file (probably csblog.php).
Then you can change your route
You might want to check on this expression to make sure if that would be the redirect you want to do. Then, you want to add a RewriteRul on your htaccess file. Maybe, something similar to this would work:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} csblog\/post [NC]
RewriteRule ^(.*)csblog\/post$ $1blog [NE,R=301,L]
</IfModule>
Options -Indexes -MultiViews
Ever time that you change your htaccess, you may want to clear your browsing history and test it to see if it works.

kohana dynamic uri routing to redirect to a controller function

I have to write a route in kohana for the following
$this->request->redirect("/" . input::post('custom_url'));
example if the custom_url = testpage
then it should be 'abc.com/testpage' and it should be redirected to a controller function example contoller/profile.
example if the custom_url = testpage1
then it should be 'abc.com/testpage1'
Route::set('event', '(event(/<url>))')
->defaults(array(
'controller' => 'event',
'action' => 'profile',
));
my url will be domainname/event/customname and it should redirect to event/profile. where event is controller and profile is action

Changes in module_menu() aren't applying

I have a custom module called tf_partner. I just modified this to include another argument. Inside the module I have:
function tf_partner_menu()
{
//... more code.....
$items['partner/letters/word/replace/%/%/%/%'] = array(
'page callback' => 'tf_partner_replace_image',
'access callback' => TRUE,
'page arguments' => array(4, 5, 6, 7),
'type' => MENU_CALLBACK,
'file' => 'tf_partner_letters.inc.php',
);
//...more code
}
This is what it used to be ...
function tf_partner_menu()
{
//... more code.....
$items['partner/letters/word/replace/%/%/%'] = array(
'page callback' => 'tf_partner_replace_image',
'access callback' => TRUE,
'page arguments' => array(4, 5, 6),
'type' => MENU_CALLBACK,
'file' => 'tf_partner_letters.inc.php',
);
//...more code
}
function tf_partner_replace_image($aid, $letter, $position, $randstr)
{
echo "here"; //doesn't show up
}
The problem is when I try to go to the new url, it doesn't work and goes to /partner/letters/word. I already went to admin/build/modules, but still getting the problem. I checked the database (menu_router table) and it looks correct.
EDIT: Also, I created a new function similar to this and a new menu item. I started with 1 argument and added one at a time. It allowed me up to 3. When I added the 4th one, it didn't work anymore.
clear cache on admin/settings/performance
or by emptying cache_{name} tables in database.
code looks fine, I guess menu just didn't get rebuilt.

Pass arguments to a view in Drupal 6 via custom module

I'm using Drupal 6 to run a gallery I've created. I need to take a parameter from the AJAX request lets say "food" and pass that argument to a view I've created (Views 2) where "food" is a taxonomy term that I am using to get the data I want in return. Everything is working just fine and in my module's method for loading the view I can load the entire view because in the settings you have 'if no argument get all values', but I can't seem to pass arguments to it. Here is the method...
function ajax_methods_menu()
{
$items = array();
$items['admin/settings/ajax_methods'] = array(
'title' => t('AJAX Methods settings.'),
'description' => t('Define settings for the AJAX Methods'),
'page callback' => 'drupal_get_form',
'page arguments' => array('ajax_methods_admin'),
'access arguments' => array('access administration pages'),
'type' => MENU_NORMAL_ITEM
);
$items['gateway'] = array(
'title' => 'AJAX Gateway',
'page callback' => 'ajax_methods_get_items',
'type' => MENU_CALLBACK,
'access arguments' => array('access content')
);
return $items;
}
function ajax_methods_get_items($args)
{
$content = views_get_view('All_Images');
return drupal_json(array('status' => 0, 'data' => $content->preview('default')));
exit;
}
In looking at the documentation views_get_view() doesn't seem to allow for arguments although I believe they are being passed to my ajax_methods_get_items() method. Thanks for reading!
Got it figured out, I needed to add
return arg(1);
seems to be working pretty well.

Resources