Skip to content

Commit

Permalink
Merge pull request #2091 from LuckyCyborg/4.0
Browse files Browse the repository at this point in the history
Improve the Content Module
  • Loading branch information
LuckyCyborg authored Jun 14, 2018
2 parents 38fd12c + 8079149 commit f56314e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 27 deletions.
2 changes: 1 addition & 1 deletion app/Platform/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// Define The Application Version
//--------------------------------------------------------------------------

define('VERSION', '4.0.73');
define('VERSION', '4.0.74');

//--------------------------------------------------------------------------
// Set PHP Error Reporting Options
Expand Down
58 changes: 33 additions & 25 deletions modules/Content/Controllers/Admin/Menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,18 @@ public function addPost(Request $request, $id)

$post->guid = site_url('content/' .$postId);

// Setup the Metadata.
$post->meta->menu_item_type = $type;
$post->meta->menu_item_menu_item_parent = $instance->parent_id;
$post->meta->menu_item_object = $type;
$post->meta->menu_item_object_id = $instance->id;
$post->meta->menu_item_target = null;
$post->meta->menu_item_url = null;

$post->save();

// Handle the Metadata.
$post->saveMeta(array(
'menu_item_type' => $type,
'menu_item_menu_item_parent' => $instance->parent_id,
'menu_item_object' => $type,
'menu_item_object_id' => $instance->id,
'menu_item_target' => null,
'menu_item_url' => null,
));

$post->taxonomies()->attach($taxonomy);

$taxonomy->updateCount();
Expand Down Expand Up @@ -222,16 +224,19 @@ public function addCategory(Request $request, $id)

$post->guid = site_url('content/' .$postId);

// Setup the Metadata.
$post->meta->menu_item_type = 'taxonomy';
$post->meta->menu_item_menu_item_parent = $instance->parent_id;
$post->meta->menu_item_object = 'category';
$post->meta->menu_item_object_id = $instance->id;
$post->meta->menu_item_target = null;
$post->meta->menu_item_url = null;

$post->save();

// Handle the Metadata.
$post->saveMeta(array(
// Setup the Metadata.
'menu_item_type' => 'taxonomy',
'menu_item_menu_item_parent' => $instance->parent_id,
'menu_item_object' => 'category',
'menu_item_object_id' => $instance->id,
'menu_item_target' => null,
'menu_item_url' => null,
));

$post->taxonomies()->attach($taxonomy);

$taxonomy->updateCount();
Expand Down Expand Up @@ -277,16 +282,19 @@ public function addCustom(Request $request, $id)

$post->guid = site_url('content/' .$post->id);

// Setup the Metadata.
$post->meta->menu_item_type = 'custom';
$post->meta->menu_item_menu_item_parent = 0;
$post->meta->menu_item_object = 'custom';
$post->meta->menu_item_object_id = $post->id;
$post->meta->menu_item_target = null;
$post->meta->menu_item_url = $url;

$post->save();

// Handle the Metadata.
$post->saveMeta(array(
// Setup the Metadata.
'menu_item_type' => 'custom',
'menu_item_menu_item_parent' => 0,
'menu_item_object' => 'custom',
'menu_item_object_id' => $post->id,
'menu_item_target' => null,
'menu_item_url' => $url,
));

$post->taxonomies()->attach($taxonomy);

$taxonomy->updateCount();
Expand Down Expand Up @@ -320,7 +328,7 @@ public function updateItem(Request $request, $id, $itemId)
$item->save();

// Invalidate the cached menu data.
Cache::forget('content.menus.main_menu');
Cache::forget('content.menus.' .$taxonomy->slug);

return Redirect::back()->with('success', __d('content', 'The Menu Item was successfully updated.'));
}
Expand Down
2 changes: 1 addition & 1 deletion modules/Content/Widgets/MainMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function render()
{
$siteUrl = Request::url();

$items = Cache::remember('content.menus.main_menu', 1440, function ()
$items = Cache::remember('content.menus.main-menu', 1440, function ()
{
$menu = Menu::slug('main-menu')->first();

Expand Down

0 comments on commit f56314e

Please sign in to comment.